I work with a legacy 2.1 Ansible (mid-migration to 2.9).
I have had success specifying my own private hosts (ini) file that contains 2 Groups ( ’ -i ’ ). But I cannot find the 2.1 argument to running a playbook (that has no hosts directive) against both, custom-inventory file and single-group in that inventory-file.
I tried:
- -i /path/to/file:<group_label>
- -i /path/to/file --extra-vars “hosts=<group_label>”
- -i /path/to/file --extra-vars “variable_host=<group_label>”
- -i /path/to/file -l <group_label>
…all result “ERROR! the field ‘hosts’ is required but was not set”
So I have two questions:
a) is it possible to specify both custom inventory file and individual group from that file in Ansible 2.1 ?
b) does anyone do this in Ansible 2.9 and if yes, would they share an newb-friendly example ?
For the time-being, I am splitting out my groups into distinct host files. For what its worth, the intent is to keep a hosts directive out of playbooks.
TIA Ya’ll