How do I add sudo permissions to a user created with Ansible?
Instead of
- name: create a new user
user: name=user
state=present
groups="group1, group2"
password={{ password }}
comment="Comment"
I did
- name: create a new user
user: name=user
state=present
group=primary-group
groups="sudo"
password={{ password }}
comment="Comment"
And the user was added to the sudo group.
- name: Create Deploy user
user: name={{ deploy }} comment="Deploy User" groups="sudo,admin,{{ deploy }}"
sudo: yes
Be careful of spaces in your groups list... You get the "group does not exist" if you have them.
groups="admin" will create user add in admin groups