How to create a newly created user as a sudo user using a chef

I created a custom "testuser" using a chef. How to make this user sudo user?

+4
source share
3 answers

There is a way to change a sudo group using a resource group:

group "create testuser sudo" do
  group_name 'sudo'
  members 'testuser'
  action :modify
  append true
end

Another way is to use the sudo recipe https://supermarket.chef.io/cookbooks/sudo .

The recommended way for me is to go to the sudo recipe and the unload system logic for the recipe. There you get resource configuration attributes that make your recipe code reliable.

+5
source

sudo cookbook.

sudo LWRP, ( /etc/sudoers.d)

sudo 'tomcat' do
  user      "%tomcat"    # or a username
  runas     'app_user'   # or 'app_user:tomcat'
  commands  ['/etc/init.d/tomcat restart']
end
+3

You do this the same as always, adding the user to the configuration /etc/sudoers. You can manage this file using a resource template, for example.

+2
source

Source: https://habr.com/ru/post/1669051/


All Articles