I think I overlooked something in your initial email. vars_files is usable from within a playbook, not from within a vars file. In your playbook just specify all of the vars files you want to include.
Something like: --- - name: admin-vm hosts: AdminVM vars_files: - vars/main.yml - vars/imagenames.yml roles: - role: provision You may be able to use the jinja2 include functionality to basically include other files into your main.yml, but I have never tried it. Probably best just to be more explicit and verbose in your playbook. -- Matt Martz [email protected] On January 17, 2014 at 11:35:02 AM, AmiableAlbion ([email protected]) wrote: Thanks Matt, overlooked that obvious detail (need more coffee). So, following the vars_files documentation I am still struggling. vars/main.yml vars_files: - imagenames.yml vars/imagenames.yml centos64: 52225cb3-441b-47b6-9cca-deb14d24d72f > ansible-playbook vm.yml PLAY [admin-vm] *************************************************************** TASK: [provision | Creating virtual machine instances] ************************ fatal: [10.0.0.6] => One or more undefined variables: 'centos64' is undefined FATAL: all hosts have already failed -- aborting PLAY RECAP ******************************************************************** to retry, use: --limit @/root/vm.retry 10.0.0.6 : ok=0 changed=0 unreachable=1 failed=0 I have tried using a relative and absolute paths to imagenames.yml with no luck. Thanks Albion On Friday, January 17, 2014 9:17:44 AM UTC-8, Matt Martz wrote: include_vars is a module that should be executed under a 'tasks' section. What I believe you are looking for is vars_files. See http://docs.ansible.com/playbooks_variables.html#variable-file-separation -- Matt Martz [email protected] On January 17, 2014 at 11:14:10 AM, AmiableAlbion ([email protected]) wrote: I am struggling to break out variables in the "var" directory of roles into individual files I have tried and continue to get tracebacks. I thought this would be straight forward after seeing the documentation for include_vars, but evidently I am missing something here. I was trying something like this with Ansible 1.4.4 vars/main.yml - include_vars: credentials.yml - include_vars: imagenames.yml vars/imagenames.yml centos64: 52225cb3-441b-47b6-9cca-deb14d24d72f rhel64: 364cd1c1-e958-4327-a0b4-3251da47869c > ansible-playbook vm.yml Traceback (most recent call last): File "/usr/bin/ansible-playbook", line 269, in <module> sys.exit(main(sys.argv[1:])) File "/usr/bin/ansible-playbook", line 209, in main pb.run() File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 229, in run play = Play(self, play_ds, play_basedir) File "/usr/lib/python2.6/site-packages/ansible/playbook/play.py", line 83, in __init__ ds = self._load_roles(self.roles, ds) File "/usr/lib/python2.6/site-packages/ansible/playbook/play.py", line 327, in _load_roles roles = self._build_role_dependencies(roles, [], self.vars) File "/usr/lib/python2.6/site-packages/ansible/playbook/play.py", line 192, in _build_role_dependencies role_vars = utils.combine_vars(vars_data, role_vars) File "/usr/lib/python2.6/site-packages/ansible/utils/__init__.py", line 1008, in combine_vars return dict(a.items() + b.items()) AttributeError: 'list' object has no attribute 'items' Perhaps I am abusing syntax here though ... Thanks Albion -- 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 [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out. -- 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 [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out. -- 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 [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
