Error creating group with ansible sudo/become
Solution 1:
You have told ansible to become (sudo in this case) to the user xdradmin
, which apparently has no permission to create groups. Most of the time you should become root
as this is the administrative user that will do all the tasks that require root privilege. Indeed, it's what you did with your ssh command: you became root
, not xdradmin
. Thus the command worked.
Fix your become_user
, e.g.:
become_user=root
The become user is different to the user that ansible connects to the remote system as. That is remote_user
.
remote_user=xdradmin
With these two changes, ansible will ssh to the system as user xdradmin
, then sudo to root
and finally run your task.