I am creating a user on my RHEL box with the command:
useradd -d <home_path> -m -s <shell_path> -U <name>where I want the group to be created when the user is created. The important part is the -U flag.
How do I implement this in Chef? So far I have
user 'name' do comment 'comment' shell '<shell_path>' home '<home_path>' manage_home true action :create
endI know I can create a group using the group resource, but that creates a group with a separate ID. Is there a way to implement the -U flag in the user resource?
1 Answer
No, there isn't any default method for this. If this functionality was highly critical for you, you could implement this functionality with a custom resource provider.
As you mentioned with the group resource, the typical method in Chef would be to create your group resource first, and assign it a specific gid. Then create your user resource, and give the user a uid and gid attribute that matches the gid given to the group. This gives you the result of having a userid that matches the groupid.
For example:
group 'name_group' do gid '2000' action :create
end
user 'name_user' do uid '2000' gid '2000' action :create
endReference: