Hi. Thanks for reply Kai.
Default Ansible cannot solve this problem, which I find very odd as it was a common issue that is very elegantly addressed in Pupept using Hiera. However.... a solution has been found! Have a look at: http://leapfrogonline.io/articles/2017-02-22-explicit-merging-of-ansible-variables/ https://github.com/leapfrogonline/ansible-merge-vars They have solved exactly this issue and I'm testing their plugin and so far so good. Certainly not as elegant as Puppet/Hiera but it's a working solution. Regards, Suhail. On Thu, 21 Mar 2019 at 18:49, Kai Stian Olstad <[email protected]> wrote: > > On 21.03.2019 12:58, Suhail Choudhury wrote: > > Thanks for your earlier reply Adam. > > > > So how can I combine variables for a list of "users" defined like so: > > > > *group_vars/all* > > > > users: > > - name: alice > > comment: Alice > > > > *group_vars/group1* > > > > users: > > - name: bob > > comment: Bob > > > > *host_vars/host1* > > > > users: > > - name: charlie > > comment: Charlie > > > > How can all these variables be combined using "loop" or "with_items"? > > You can't, they will be overwritten in the order listed here > https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable > > > What if there are duplicates? > > They are duplicates since all are call users and will be overwritten. > > > > Can the "host_vars/host1" variables override and take precedence over the > > "group_vars/all" variables? > > It does. > > > -- > Kai Stian Olstad > > -- > 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/86213972-a12c-474a-0284-747eaa825cdd%40olstad.com. > For more options, visit https://groups.google.com/d/optout. -- 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/CAHdO4Gnd-ukbXE2KafyFsMtTF2hjYf32Onn%3DPa0Gcz9jV7adZg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
