Quantcast
Channel: User Karthik T - Stack Overflow
Viewing all articles
Browse latest Browse all 42

In ansible what is the best way to manage Global and groupwise vars [closed]

$
0
0

Currently my playbook to create user accounts and

- name: Create the necessary users  hosts: all  become: yes  vars:    users:      - name: user1        ssh_keys:          - XXXXX      - name: user2        ssh_keys:          - YYYYY    users_to_remove: [] # array of user names to remove

The tasks to create the user follow this and are quite basic.Currently this setup creates the accounts on all hosts. I have ~15-20 hosts split in about 5 groups, and I am trying to come up with a clean solution which lets me create users in only a few specific groups instead of all groups. I would like to leave the vars in the playbook if at all possible.

I am hoping there is a way I can implement something like

- name: user2  ssh_keys:    - YYYYY  group: all # or group name

Is it possible to do this? Or is there any more prefered way to manage this?The only way I can think of is to create a full directory structure for group vars and add the dict there, possible split one dict for global users and one for users specific to a particular group and merge (Since ansible doesnt merge the vars right? AFAIK the group vars just overwrite the global vars)


Viewing all articles
Browse latest Browse all 42

Trending Articles