The groups parameter is a simple list of strings. It is clearly documented 
in the module description.

*groups: [ "{{ username }}", "{{ groupname }}" ]*

On Friday, July 1, 2022 at 1:40:45 PM UTC-4 [email protected] wrote:

> You can use groups_vars for any group in your inventory
>
> Enviado desde mi iPhone
>
> El 01-07-2022, a la(s) 13:32, Tony Wong <[email protected]> escribió:
>
> any idea how I can create a user and then put it into multiple groups 
> with jinja2?
>
>
> - name: create user sam
>   ansible.builtin.user:
>     name: '{{ username }}'
>     shell: '{{ shell }}'
>     generate_ssh_key: yes
>     create_home: yes
>     groups: "'{{ username }}','{{ groupname }}'"
>     append: yes  
>     ssh_key_file: .ssh/id_rsa
>   become: true
>
>
> where {{ username }} is sam 
> {{ groupname }} is docker
>
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/5bb32ddb-57be-4133-aa03-22a1ff06a542n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/ansible-project/5bb32ddb-57be-4133-aa03-22a1ff06a542n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bf62cf3a-c7e7-44b5-b2cd-ec3aa8dc86f0n%40googlegroups.com.

Reply via email to