Problems with Ansible host definitions

Søren Sjøstrøm
Søren Sjøstrøm used Ask the Experts™
on
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:
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   

Open in new window


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 

Open in new window

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

Open in new window

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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Commented:
Shouldn't it be:  (as replacement for the current dmzservers)

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial