Is there a way (or would a patch be welcomed??) to allow cleanly supplying variables to included tasks/playbooks/etc. similar to with_items? E.g.
tasks:
- include: $task_dir/leiningen-install.yml
- include: $task_dir/push-ansible.yml
vars:
push_ansible_version: devel
push_ansible_dir: ~/src/ansible-devel
– VS. –
tasks:
- include: $task_dir/leiningen-install.yml
- include: $task_dir/push-ansible.yml push_ansible_version=devel push_ansible_dir=~/src/ansible-devel
Also; it seems that variables are not shared when passing playbooks (I load a lot of common variables via a vars_file, and then include playbooks where I need to re-include the vars_file). Is this a possibility?
Thanks,
~ Brice
Pretty sure Daniel already made that work, at least for playbook
includes, at one point.
He'll have to remind me
Michael DeHaan wrote:
Pretty sure Daniel already made that work, at least for playbook
includes, at one point.
He'll have to remind me
Yep, vars: works on both task includes and playbook includes. Probably needs
to get documented though...
Is there a way (or would a patch be welcomed??) to allow cleanly
supplying
variables to included tasks/playbooks/etc. similar to with_items? E.g.
tasks:
- include: $task_dir/leiningen-install.yml
- include: $task_dir/push-ansible.yml
vars:
push_ansible_version: devel
push_ansible_dir: ~/src/ansible-devel
-- VS. --
tasks:
- include: $task_dir/leiningen-install.yml
- include: $task_dir/push-ansible.yml push_ansible_version=devel
push_ansible_dir=~/src/ansible-devel
Also; it seems that variables are not shared when passing playbooks (I
load
a lot of common variables via a vars_file, and then include playbooks
where
I need to re-include the vars_file). Is this a possibility?
No, vars are per play, and there are no global vars. If you aren't using any
of the vars_files specialities, you could likely just use group_vars/all to
contain your variables, and completely avoid using vars_files.
Daniel
+1
This would be very useful!