File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -939,10 +939,13 @@ def user(
939939 args .append ("-g {0}" .format (group ))
940940
941941 # Check secondary groups, if defined
942- if groups and set ( existing_user [ "groups" ]) != set ( groups ) :
942+ if groups :
943943 if append :
944- args .append ("-a" )
945- args .append ("-G {0}" .format ("," .join (groups )))
944+ if not set (groups ).issubset (existing_user ["groups" ]):
945+ args .append ("-a" )
946+ args .append ("-G {0}" .format ("," .join (groups )))
947+ elif set (existing_user ["groups" ]) != set (groups ):
948+ args .append ("-G {0}" .format ("," .join (groups )))
946949
947950 if comment and existing_user ["comment" ] != comment :
948951 args .append ("-c '{0}'" .format (comment ))
@@ -965,7 +968,10 @@ def user(
965968 if group :
966969 existing_user ["group" ] = group
967970 if groups :
968- existing_user ["groups" ] = groups
971+ if append :
972+ existing_user ["groups" ] += groups
973+ else :
974+ existing_user ["groups" ] = groups
969975 if password :
970976 existing_user ["password" ] = password
971977
You can’t perform that action at this time.
0 commit comments