Hi,
A new ansible user here... I've been perusing the mailing list archives and 
have gathered a lot of useful tidbits.

I've been fairly successful in figuring out how to create a set of users on 
a list of hosts. However, what I'm not so clear about is how to create 
different sets of users on different categories of hosts. We're a software 
house that administrates the server farms at our customers. Let's say we 
have 20 customers, and each customer can have 3-20 servers; these servers 
fall into different categories as well: application servers, database 
servers, test app. servers, test DB servers for example.

One set of users should be created on all systems always, namely our 
sysadmins.
Another set of users should only be created on the database servers; 
likewise for the application servers.

The approach I'd find logical would be to write a playbook such as:

- hosts: all_hosts
  tasks:
  - name: Add sysadmin users
    user: name={{ item.key }} password={{ item.value.password }} uid={{ 
item.value.uid }} group={{ item.value.group }} groups="" comment="{{ 
item.value.comment }}" state={{ item.value.state }} update_password=always
    with_dict: sysadmin_user
 
- hosts: db_hosts
  tasks:
  - name: Add DBA users
    user: name={{ item.key }} password={{ item.value.password }} uid={{ 
item.value.uid }} group={{ item.value.group }} groups="" comment="{{ 
item.value.comment }}" state={{ item.value.state }} update_password=always
    with_dict: dba_user
 
- hosts: application_hosts
  tasks:
  - name: Add application users
    user: name={{ item.key }} password={{ item.value.password }} uid={{ 
item.value.uid }} group={{ item.value.group }} groups="" comment="{{ 
item.value.comment }}" state={{ item.value.state }} update_password=always
    with_dict:appl_user

This would work, but would entail listing all hosts at least twice: once 
for the "all_hosts" list, and once for the specific type of host. I'd like 
to be able to compose the "all_hosts" list automatically out of the other 
lists. I've tried a couple of ways after reading things in the mailing list 
archive that might be applicable, but haven't had any success.

So, in short, my question really boils down to: Is it possible to merge 
existing host lists so that I don't have to repeat hosts in different 
lists?  The same question also applies to user lists, although I suspect 
that if it's possible with host lists, the same method will work for user 
lists as well.

(Being able to merge host lists would mean it would be possible to define 
hosts in lists according to customer + type, and then build different host 
lists such as "all DB hosts" or "all hosts at customer XYZ".)


Thanks!

-- 
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/d2a85755-f820-4826-9c2f-63bb8ed19328%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to