On Wednesday, February 26, 2014 1:05:33 AM UTC-8, Petr Sukharev wrote:
>
> Thanks for you reply, Adam!
> I think, this solution is working like charm, but main reason for defined 
> users like variables - is keeping all information in separate file. It is 
> more simple for managing information and apply changes...
> For example, if i have 10 host groups and 40 users, and changing some 
> information or add field for user - i need to change each entry in my 
> playbook (or multiple playbooks). If i use separate file - i need to change 
> only this file :)
>
>
I would suggest that you put the variables into some kind of vars file 
(group_vars if they are different for different groups)

then you can use the same playbook and task... If you add fields you may 
want to change the tasks to apply the fields...


So with your inventory file...

[group_1]
host_1
host_2

[group_2]
host_3
host_4


You would have a playbook that would have something like
---
- hosts: all
  tasks:
  - name: Add ssh user
    user: name={{ item.user }} shell={{ item.shell }} groups='admins'
    with_items: {{ ssh_users }}

then you would have a group_vars directory with a group_1 file and a 
group_2 file each one looking like...

ssh_users:
  - {{ name: user1, shell: /bin/ksh }}
  - {{ name: user2, shell: /bin/bash }}

host_1 and host_2 would create the users from group_1 while host_3 and 
host_4 would create the users from group_2

I hope that this helps,

Adam

 

-- 
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/3fc02967-6ffb-4ace-a81e-7efad8320900%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to