Another great way of doing it!
What I'm going to do is just a playbook to setup the basic Shinken system. 
And the Shinken user should only be member of the group shinken.

Den tisdagen den 20:e maj 2014 kl. 14:39:54 UTC+2 skrev Ernest0x:
>
>  On 05/20/14 15:05, Joachim Friberg wrote:
>  
> You are the best! This should go in to the andible-docs.
> I Just needed to modify it a small bit.
> Here's the end result and code:
>
>  - name: Prepare for Shinken|user
>   user: name={{ item.0.name }}
>         comment={{ item.0.comment }}
>         group={{ item.1 }}
>         shell={{ item.0.shell }}
>         password={{ item.0.password }}
>         state=present
>         update_password=on_create
>         append=yes
>   with_subelements:
>    - users
>    - group
>  
>  ---
> users:
>   - name: shinken
>     comment: "Shinken.user"
>     group:
>      - "shinken"
>     shell: "/bin/bash"
>     password: 
> "$6$cGTFMo0u$DPyI81Yn/9lFbAVMtTRy0vSXfn00ZaeBPg754BzDx7Aj6B6WZGicfjOjkeY9upT8HPvKV2voQ1SNuWIF2hfEi/"
>  
> Also tried it with multiple entries into the "user-list" in the var-file 
> and this worked too. 
> Thank you!
>  -- 
> 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] <javascript:>.
> To post to this group, send email to [email protected]<javascript:>
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/242d00c7-b03d-46b6-bda7-b26c8e22cef1%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/242d00c7-b03d-46b6-bda7-b26c8e22cef1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> I think the above loop is not correct for what you want to do. You are 
> using the 'group' parameter of the user module, which sets the primary 
> group. So, it will reset it on each loop iteration.
>
> Also, you are using a key named 'group' with a list value, which seems not 
> to be indicative of what you want to deploy. What is it meant for? Is it 
> meant to be a list of the groups the user must be member of? Then rename it 
> to 'groups'. Is it meant to be the primary group of the user? Then rename 
> it to 'primary_group'. In either case, it seems that what you want can be 
> done with a simple 'with_items' loop. No need for a 'with_subelements' 
> loop. 
>
> For example:
>
>  - name: Prepare for Shinken|user
>   user: name={{ item.name }}
>         comment={{ item.comment }}
>         groups={{ item.groups|join(',') }}
>         shell={{ item.shell }}
>         password={{ item.password }}
>         state=present
>         update_password=on_create
>   with_items: users
>  
>  ---
> users:
>   - name: shinken
>     comment: "Shinken.user"
>     groups:
>      - "shinken"
>     shell: "/bin/bash"
>     password: 
> "$6$cGTFMo0u$DPyI81Yn/9lFbAVMtTRy0vSXfn00ZaeBPg754BzDx7Aj6B6WZGicfjOjkeY9upT8HPvKV2voQ1SNuWIF2hfEi/"
>  
>
>  

-- 
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/73a03d6b-f998-4092-b4cf-90c44eac4eb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to