Hello again,
I am still experiencing issues with this. I reply first here in case what I am doing is blatantly evident.
Since then, this issue was closed and new documentation produced:
https://github.com/ansible/ansible/issues/5227
http://docs.ansible.com/playbooks_loops.html?highlight=loops#finding-first-matched-files
This is good, however, I keep experiencing something undesirable.
So this is Centos 6.5, Ansible 1.4.3-1
This is to distribute a configuration that may be different in function of the host type. The reason does not matter.
In the templates directory:
…/roles/common/templates$ ls -lrt sssd
-rw-rw-r-- 1 guillem guillem 723 Jan 12 21:25 sssd.conf.j2
-rw-rw-r-- 1 guillem guillem 789 Jan 18 12:53 ndoluxel001.sssd.conf.j2
In the playbook:
- name: Make sure SSSD configuration is correct.
template: src={{ item }} dest=/etc/sssd/sssd.conf
with_first_found:
- “{{ inventory_hostname }}.sssd.conf.j2”
- sssd.conf.j2
This is exactly as shown in the documentation:
http://docs.ansible.com/playbooks_loops.html?highlight=loops#finding-first-matched-files
- name: INTERFACES | Create Ansible header for /etc/network/interfaces template: src={{ item }} dest=/etc/foo.conf with_first_found: - “{{ansible_virtualization_type}_foo.conf” - “default_foo.conf”
However when I run the play book:
ansible-playbook /etc/ansible/common.yml --tags=“auth” -k
SSH password:
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [ndoluxel001]
ok: [ndoandel001]
ok: [ndoluxel002]
TASK: [common | Make sure SSSD configuration is correct.] *********************
fatal: [ndoluxel001] => input file not found at /etc/ansible/roles/common/templates/None or /etc/ansible/None
fatal: [ndoluxel002] => input file not found at /etc/ansible/roles/common/templates/None or /etc/ansible/None
fatal: [ndoandel001] => input file not found at /etc/ansible/roles/common/templates/None or /etc/ansible/None
FATAL: all hosts have already failed – aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/common.retry
ndoandel001 : ok=1 changed=0 unreachable=1 failed=0
ndoluxel001 : ok=1 changed=0 unreachable=1 failed=0
ndoluxel002 : ok=1 changed=0 unreachable=1 failed=0
What would I expect:
ndoluxel001 to obtain configuration from template ndoluxel001.sssd.conf.j2
The others to obtain the default sssd.conf.j2 template.
Things I have tried already:
- The way jctanner proposes me to fix it, which did not work, actually complains of a syntax error.
- Use underscore instead of dots.
- Qualifying the search paths, relative and absolute. Nothing.
- Switching verbosity, not very cool as it gives me things I do not need and still I do not see what is going on behind the curtain:
TASK: [common | Make sure SSSD configuration is correct.] *********************
ESTABLISH CONNECTION FOR USER: root on PORT 22 TO ndoluxel001
ESTABLISH CONNECTION FOR USER: root on PORT 2022 TO ndoandel001
ESTABLISH CONNECTION FOR USER: root on PORT 22 TO ndoluxel002
EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1390047005.86-11603493989537 && echo $HOME/.ansible/tmp/ansible-1390047005.86-11603493989537’
fatal: [ndoluxel001] => input file not found at /etc/ansible/roles/common/templates/None or /etc/ansible/None
EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1390047006.29-141184342231390 && echo $HOME/.ansible/tmp/ansible-1390047006.29-141184342231390’
EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1390047006.45-261013738830940 && echo $HOME/.ansible/tmp/ansible-1390047006.45-261013738830940’
fatal: [ndoluxel002] => input file not found at /etc/ansible/roles/common/templates/None or /etc/ansible/None
fatal: [ndoandel001] => input file not found at /etc/ansible/roles/common/templates/None or /etc/ansible/None
I really hope that this is something simple that I am missing.
Many thanks in advance.