- include_vars: '{{item}}'
with_first_found:
- "{{ansible_hostname}}.yml"
- default.yml
Then I have firewall/vars/default.yml and firewall/vars/HOSTNAME.yml, where HOSTNAME is my hostname.
However, when I include this role in a playbook and run it, I get:
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [firewall | include_vars ] **********************************************
fatal: [localhost] => input file not found at /Users/anandb/git/gii-ansible/playbooks/roles/firewall/vars/None or /Users/anandb/git/gii-ansible/playbooks/None
FATAL: all hosts have already failed -- aborting
Any idea what is happening here?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
If you run the setup module on localhost, is 'ansible_hostname' correctly filled in?
$ ansible localhost -m setup | grep ansible_hostname
"ansible_hostname": "clabbers",
My laptop is called "clabbers".
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Yep, I can replicate this.
include_vars is new for 1.4.X so we probably missed a possible use case that someone would want to try.Please file a github ticket.
Meanwhile, you can work around this in a play like so:
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/UQ_ArPEofFU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
i believe i had run into something very similar, if not identical, trying to follow Michael's original post on this. my solution ended up being to reference the vars dir relatively as opposed to assuming ansible could just find it; my bad for not submitting a bug. Anand, does something like this work for you?- include_vars: "{{ item }}"with_first_found:- ../vars/{{ ansible_hostname }}.yml- ../vars/default.yml
Ah yeah, this much is true, because the native search path for roles files is in "./files".This is actually the way lookup plugins work, and it's fine.I had inadvertedly done my non-roles testing without naming the filename correctly so this is working for me too.Good, not a bug!
--