Thanks for the quick reply. However I don't think it works.
Maybe I was not clear. Here is a small test case to demonstrate the issue:
proj1/inventory/hosts.yml
all:
vars:
bar: from 1 all
hosts:
example1.com:
proj2/inventory/hosts.yml
all:
vars:
bar: from 2 all
hosts:
example2.com:
proj3/playbook.yml
- hosts: example1.com
connection: local
tasks:
- debug:
var: bar
And run the playbook with
ansible-playbook -i ../proj1/inventory -i ../proj2/inventory playbook.yml
Apparently proj2's all.vars will override proj1's, so bar shows "from 2
all", which is not what I want.
I want proj3's inventory to have two groups, group1 and group2, where
proj1's all.vars become group1's group vars, ditto for proj2, so all.vars
don't get overridden. In the test case, I'd like bar to be "from 1 all"
Is this something possible to do?
On Wednesday, October 19, 2022 at 9:20:40 PM UTC+8 Brian Coca wrote:
> You can just reference both when calling ansible-playbook:
>
> ansible-playbook -i /inv1 -i /inv2 play.yml
>
> Or If you want a static copy:
>
> ansible-inventory -i /inv1 -i /inv2 --exports --list --yaml > newmerged.yml
>
>
> --
> ----------
> Brian Coca
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ea5a00e0-1335-48cc-99be-cc731714e985n%40googlegroups.com.