Has anyone come across this before? Surely it must be a common ask.
On Wednesday, 27 February 2019 15:15:59 UTC, Suhail Choudhury wrote:
>
> Hi,
>
> I want to know how I can import user account variables at multiple levels
> using loops/arrays and importing them all.
>
> i.e. i have a generic module which has users defined in
> roles/common/tasks/main.yml as an array(or loop if more precise):
>
> - name: add admin users on RHEL
> user:
> name: "{{ item.username }}"
> comment: "{{ item.comment }}"
> state: present
> groups: wheel
> shell: /bin/bash
> password: "{{ item.password }}"
> with_items: "{{ users }}"
> when: ansible_facts["os_family"] == "RedHat"
> tags: common
>
> and the user attributes are all set as variables and the variables for
> these users are being picked up from roles/common/vars/main.yml
>
> I also have user variables defined under group_vars/dev and group_vars/prd
>
> And I also have specific users defined at host level under
> host_vars/server1
>
> Now the problem is that Ansible is only picking up users from one level,
> whilst I want to pick up all the user variables from all levels, i.e.
> sysadmins, dev users & specific host users, and add them all in, not just
> from the most preferred variable source.
>
> In Puppet this is achieved by using Hiera and "hiera_hash" which allows
> variable values to get collectively applied from all hiera levels.
>
> How can the same be achieved with Ansible please?
>
> Regards,
> Suhail.
>
--
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/29923dd1-85b2-4748-8858-b7894f588dbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.