Error: UID 900 already exists, use allowdupe to force user creation
Error: /Stage[main]/Localusers::Identities/User[user1]/groups: change from to 'group1,group2' failed: UID 900 already exists, use allowdupe to force user creation
So far I have found two issues.
# lusermod --help
Usage: lusermod [OPTION...] user
-i, --interactive prompt for all information
-c, --gecos=STRING GECOS information
-d, --directory=STRING home directory
-m, --movedirectory move home directory contents
-s, --shell=STRING set shell for user
-u, --uid=NUM set UID for user
-g, --gid=NUM set primary GID for user
-l, --login=STRING change login name for user
-P, --plainpassword=STRING plaintext password for the user
-p, --password=STRING pre-hashed password for the user
-L, --lock lock account
-U, --unlock unlock account
--commonname=STRING set common name for user
--givenname=STRING set given name for user
--surname=STRING set surname for user
--roomnumber=STRING set room number for user
--telephonenumber=STRING set telephone number for user
--homephone=STRING set home telephone number for user
Help options:
-?, --help Show this help message
--usage Display brief usage message
2) the new code will not "modify" the user's groups in /etc/group because the user already exists.