OK, so I looked at Ansible's code, and I now know how to implement this.
I tried my modification locally and
it works fine. It basically adds a module that adds an 'extra_vars'
variable if it does not yet exist.
That way, any variable set on the commandline using the '--extra-vars'
argument cannot be overruled by the
playbook.
Now this scenario works :
Inventory :
group_all = { host_1, host_2, host_3 }
group_one = { host_1 }
group_two = { host_2, host3 }
Playbook 'my_playbook.yml' :
---
- hosts: group_one
tasks:
- name: list /tmp
shell: ls /tmp
register: out
- name: set global variable
setglobal: name=myvar value="{{out}}"
- hosts: group_two
tasks:
- debug: msg="{{myvar}}"
command : 'ansible-playbook my_playbook.yml --limit group_all'
Anyone interested in this modification ? I can create a pull request...
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/e8f483b0-e215-4675-93ba-8243d19f5504%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.