Efficient way to disable a user to sudo via puppet
by sparkling from LinuxQuestions.org on (#4RNSM)
I have puppet 6 installed in my environment and would like to ensure that the user centos cannot sudo on all of my agents. I can create somethings like this:
Code:modules/sudoer/manifests/disable_sudo.pp
# Manage the sudoers file
class sudoers {
file { '/etc/sudoers':
source => 'puppet:///modules/sudoers/sudoers',
mode => '0440',
owner => 'root',
group => 'root',
}
}And then create a "modules/sudoers/files/sudoers" file and put the content I like in there and make sure the centos line is commented out:
Code:#centos ALL=(ALL) NOPASSWD: ALLBut this is very lengthy and in puppet 3, I could only use sudo::disable_centos: true in the hiera. Is there a better way for letting puppet prevent the user centos from sudo? Thank you


Code:modules/sudoer/manifests/disable_sudo.pp
# Manage the sudoers file
class sudoers {
file { '/etc/sudoers':
source => 'puppet:///modules/sudoers/sudoers',
mode => '0440',
owner => 'root',
group => 'root',
}
}And then create a "modules/sudoers/files/sudoers" file and put the content I like in there and make sure the centos line is commented out:
Code:#centos ALL=(ALL) NOPASSWD: ALLBut this is very lengthy and in puppet 3, I could only use sudo::disable_centos: true in the hiera. Is there a better way for letting puppet prevent the user centos from sudo? Thank you