I want to have a set of git repos with base application config playbooks in them such that all I need to do with any VM, regardless of its name or role or how long its been around, to get the base config installed is to run an ansible-pull command against this repo and I get a ready to use instance. The problem that I run into is that if I have a playbook local.yml that's set like so:
- hosts: localhost
connection: local
gather_facts: yes
user: root
[...]
or like so:
- hosts: all
connection: local
gather_facts: yes
user: root
[...]
I keep getting the following error:
# ansible-pull -d /tmp/myrepo -U 'http://mygithost/myrepo'
Starting ansible-pull at 2015-06-09 15:04:05
localhost | success >> {
"after": "2e4d1c637170f95dfaa8d16ef56491b64a9f931b",
"before": "d7520ea15baa8ec2c45742d0fd8e209c293c3487",
"changed": true
}
**ERROR: Specified --limit does not match any hosts**
The only way I've been able to avoid the error is to create an explicit inventory file with an explicit groupname and explicit hostnames that is then referred to with the '-i' flag like so:
# cat /tmp/myrepo/myinventory
[mygroup]
myhost1
myhost2
# cat /tmp/myrepo/local.yml
- hosts: mygroup
connection: local
gather_facts: yes
user: root
[...]
# ansible-pull -d /tmp/myrepo -i myinventory -U 'http://mygithost/myrepo'
But I don't want that, I want any host, no matter whether its name or role is known to be able to run an ansible-pull against the repo and run the playbook without having to explicitly configure the name of the host into the inventory. How do I do that?
Here is the workflow I use for ansible-pull
within my VMs:
In the base VM I put a file named hosts
at /etc/ansible
:
# cat /etc/ansible/hosts
localhost ansible_connection=local
My local.yaml
starts with
- hosts: localhost
gather_facts: yes
user: root
...
Now I can use ansible-pull without specifying a hosts file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With