Søren Sjøstrøm
asked on
Problems with Ansible host definitions
Currently I am setting up a Configuration Management System via Ansible.
My playbook site.yml is built with tags so I can start the different parts of the configuration individually.
The first part of the playbook works almost fine - I can run this part via the command "ansible-playbook site.yml --tags initial_config". All machines in my host group (hosts: dmzservers:!raspberrypi) are configured as expected. However, with the exception that a machine outside the host group is also attempted to configure:
But when I want to run the next part, my base setup, things start to go more wrong. Here too, the host definition is "hosts: dmzservers:!raspberrypi", so it should be the same machines that are configured. But none of the expected machines in the host group is configured. On the other hand, the same machine that is not part of the host group is trying to configure.
I think my host definition file complies with what is described here: https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html. But something I do wrong - just can't figure out what.
My host configuration, playbook and ansible.cfg file are attached.
Happy New Year to everyone :-)
site.yml
hosts.yml
ansible.cfg
My playbook site.yml is built with tags so I can start the different parts of the configuration individually.
The first part of the playbook works almost fine - I can run this part via the command "ansible-playbook site.yml --tags initial_config". All machines in my host group (hosts: dmzservers:!raspberrypi) are configured as expected. However, with the exception that a machine outside the host group is also attempted to configure:
PLAY RECAP
auth.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
backend.dmz.tuxme.dk : ok=43 changed=1 unreachable=0 failed=0
db.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
develop.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
gateproxy.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
intra.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
ispconf.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
kolab.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
mail.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
mailproxy.dmz.tuxme.dk : ok=42 changed=1 unreachable=0 failed=0
master.lan.tuxme.dk : ok=0 changed=0 unreachable=0 failed=1
mastodon.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
proxy.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
web.dmz.tuxme.dk : ok=42 changed=0 unreachable=0 failed=0
But when I want to run the next part, my base setup, things start to go more wrong. Here too, the host definition is "hosts: dmzservers:!raspberrypi", so it should be the same machines that are configured. But none of the expected machines in the host group is configured. On the other hand, the same machine that is not part of the host group is trying to configure.
PLAY RECAP
master.lan.tuxme.dk : ok=0 changed=0 unreachable=0 failed=1
It seems that the entire list of machines to be configured has been lost. If I run the command "ansible-playbook site.yml --tags base_install -v" I get the message:Using /etc/ansible/ansible.cfg as config file
/Users/soren/Ansible/inventories/production/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/Users/soren/Ansible/inventories/production/hosts did not meet script requirements, check plugin documentation if this is unexpected
I have both tried to create the hosts file in yaml format and ini format, but the message is still the same.I think my host definition file complies with what is described here: https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html. But something I do wrong - just can't figure out what.
My host configuration, playbook and ansible.cfg file are attached.
Happy New Year to everyone :-)
site.yml
hosts.yml
ansible.cfg
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
alldmzservers:
dmzservers:
hosts:
auth.dmz.tuxme.dk:
backend.dmz.tuxme.dk:
db.dmz.tuxme.dk:
develop.dmz.tuxme.dk:
gateproxy.dmz.tuxme.dk:
intra.dmz.tuxme.dk:
ispconf.dmz.tuxme.dk:
kolab.dmz.tuxme.dk:
mail.dmz.tuxme.dk:
mailproxy.dmz.tuxme.dk:
mastodon.dmz.tuxme.dk:
proxy.dmz.tuxme.dk:
web.dmz.tuxme.dk:
raspberrypi:
hosts:
tools.dmz.tuxme.dk:
Then All dmzhosts selects all hosts, dmzhosts only selects the nonraspberry pi ones...
the alldmzhosts wil also select the raspberrypi.
I'm not 100% sure though as i have no need to get ansible up & running.