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.