Hello. I often want to run a playbook against an arbitrary host, sometimes one not defined in my inventory hosts file. Is there a way of specifying an arbitrary hostname or IP on the ansible-playbook command line to run things this way? It’s a pain to have to edit the inventory each time I want to run something against a temporary machine (e.g. for testing).
Thanks.
-Pete
-i 'myhost,' will define an inventory on the command line where you
can add any host/ip you want.
^ observe the , is needed even if only 1 host is defined to signify
this is a list and not a path to a file
Hi, Brian. I’m trying to run a playbook file which by definition must contain a “hosts” entry. When I run the ansible-playbook command with the “-i” flag, I get this:
`
ansible-playbook -i ‘10.10.10.155,’ -u root do_base_packages.yaml
PLAY [dummy] ******************************************************************
skipping: no hosts matched
`
…where “dummy” is the hosts entry in the playbook file. The playbook file looks like this:
`
- hosts: dummy
become: yes
roles:
- role: base
- role: ntp
ntp_server: [10.10.10.11, 10.10.10.12, 10.20.10.11]
ntp_restrict:
- “restrict 127.0.0.1”
`
How do I force a host on the command line without needing to define it in the playbook file or in the inventory? I’m on OSX 10.10.5 and Ansible 1.9.2.
Thanks!
-Pete
-i 'dummy,' -e 'ansible_ssh_host=<whatever>'