Adding a user to an additional group using ansible

According to the User module you can use this:

- name: Adding user {{ user }}  
  user: name={{ user }}
        group={{ user }}
        shell=/bin/bash
        password=${password}
        groups=sudo
        append=yes

You can just add the groups=groupname and append=yes to add them to an existing user when you’re creating them

Leave a Comment