ansible/ansible — pull request #3470 by langemeijer (2013-07-08 09:58:42+00:00)
Title: Only append non_unique parameter if a uid is provided as well to user module

I use this line in a playbook:
action: user name=backups uid=33 home="/home/backups" non_unique=yes group=www-data

User creation works fine, but the next run I get the error:
msg: usermod: -o flag is only allowed with the -u flag

This is because the info[2] != int(self.uid) condition is not true (uid is not modified) on executing usermod. If this is the case the -o flag should not be added.

Also in this commit: -o should not be added to useradd if the uid is not set according to the useradd manpage. Granted, this should never occur, if a user adds non_unique=yes in ansible they should provide uid. I changed useradd too to silently drop the -o flag if this happens.