adding new users to /etc/sudoers

905 views
Skip to first unread message

manyi

unread,
Mar 27, 2015, 3:24:58 PM3/27/15
to puppet...@googlegroups.com

Help needed!!

I am trying to add 2 users to /ect/sudoers john.smith and jane.may granting privileges to all servers

step 1. modules/user/manifests/init.pp


class user {

 user { 'john.smith':

 ensure => present,

 comment => 'john.smith',

 home => '/home/john.smith',

 managehome => true

   }

}


Step 2  manifests/site.pp

 

/etc/puppet/manifests/site.pp

node 'mydomain.local.org'

 { include user }


step 3 : sudo mkdir -p modules/sudoers/manifests

Step 4   sudo mkdir -p modules/sudoers/files

step 5 

Create the file modules/sudoers/manifests/init.pp

# Manage the sudoers file

 class sudoers {

file { '/etc/sudoers':

 source => 'puppet:///modules/sudoers/sudoers'

 mode => '0440',

owner => 'root',

 group => 'root',

   }

}


Step 6 Check the syntax of the sudoers file

visudo -c -f modules/sudoers/files/sudoers modules/sudoers/files/sudoers

output:

usage: visudo [-chqsV] [-f sudoers]

step 7:

back in manifests/site.pp

node 'mydomain.local.org' {

include user

include sudoers

}

step 8

puppet$ sudo puppet agent --test

does respond


I finally tried:

node 'mydomain.local.org' {

  class { 'sudo': }

  sudo::conf { 'john.smith':

    priority => 10,

    source   => 'puppet:///files/etc/sudoers.d/users/john.smith',

   }

}


still the agent doesn't respond

can someone point me to the right direction please

Russell Anderson

unread,
Mar 28, 2015, 10:40:20 AM3/28/15
to puppet...@googlegroups.com
First, the visudo check didn't work otherwise it would have given actual feedback, not usage info. 

Second, where is this sudo class / module come from.  Nothing in the command snippets creates it. 

manyi

unread,
Mar 30, 2015, 8:50:24 AM3/30/15
to puppet...@googlegroups.com
Thanks for the responds Russel,
responding to where the sudo class /module is from, I created it
any pointers???

Garrett Honeycutt

unread,
Mar 30, 2015, 2:26:54 PM3/30/15
to puppet...@googlegroups.com
On 3/30/15 2:50 PM, manyi wrote:
> Thanks for the responds Russel,
> responding to where the sudo class /module is from, I created it
> any pointers???
>
>
>
> On Saturday, March 28, 2015 at 10:40:20 AM UTC-4, Russell Anderson wrote:
>
> First, the visudo check didn't work otherwise it would have given
> actual feedback, not usage info.
>
> Second, where is this sudo class / module come from. Nothing in the
> command snippets creates it.
>
> On Friday, March 27, 2015 at 3:24:58 PM UTC-4, manyi wrote:
>
> Help needed!!
>
> I am trying to add 2 users to /ect/sudoers john.smith and
> jane.may granting privileges to all servers
>
> _*step 1. *__*modules/user/manifests/init.pp *_
>
>
> class user {
>
> user { 'john.smith':
>
> ensure => present,
>
> comment => 'john.smith',
>
> home => '/home/john.smith',
>
> managehome => true
>
> }
>
> }
>
>
> _*Step 2 manifests/site.pp*_
>
>
>
> /etc/puppet/manifests/site.pp
>
> node 'mydomain.local.org <http://mydomain.local.org>'
>
> { include user }
>
>
> _*step 3 :*_ sudo mkdir -p modules/sudoers/manifests
>
> _*Step 4*_ sudo mkdir -p modules/sudoers/files
>
> step 5
>
> Create the file modules/sudoers/manifests/init.pp
>
> # Manage the sudoers file
>
> class sudoers {
>
> file { '/etc/sudoers':
>
> source => 'puppet:///modules/sudoers/sudoers'
>
> mode => '0440',
>
> owner => 'root',
>
> group => 'root',
>
> }
>
> }
>
>
> _*Step 6 *_Check the syntax of the sudoers file
>
> visudo -c -f modules/sudoers/files/sudoers
> modules/sudoers/files/sudoers
>
> _*output*_:
>
> usage: visudo [-chqsV] [-f sudoers]
>
> step 7:
>
> back in manifests/site.pp
>
> node 'mydomain.local.org <http://mydomain.local.org>' {
>
> include user
>
> include sudoers
>
> }
>
> step 8
>
> puppet$ sudo puppet agent --test
>
> does respond
>
>
> I finally tried:
>
> node 'mydomain.local.org <http://mydomain.local.org>' {
>
> class { 'sudo': }
>
> sudo::conf { 'john.smith':
>
> priority => 10,
>
> source => 'puppet:///files/etc/sudoers.d/users/john.smith',
>
> }
>
> }
>
>
> still the agent doesn't respond
>
> can someone point me to the right direction please
>

Hi Manyi,

Suggest checking out saz/sudo[1] instead of rolling your own.

[1] - https://github.com/saz/puppet-sudo

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

manyi

unread,
Mar 30, 2015, 3:50:16 PM3/30/15
to puppet...@googlegroups.com
I'' check it out thanks Garrett


On Friday, March 27, 2015 at 3:24:58 PM UTC-4, manyi wrote:

Help needed!!

I am trying to add 2 users to /ect/sudoers john.smith and jane.may granting privileges to all servers

step 1. modules/user/manifests/init.pp


class user {

 user { 'john.smith':

 ensure => present,

 comment => 'john.smith',

 home => '/home/john.smith',

 managehome => true

   }

}


Step 2  manifests/site.pp

 

/etc/puppet/manifests/site.pp

node 'mydomain.local.org'

 { include user }


step 3 : sudo mkdir -p modules/sud

...

Brian Morris

unread,
Apr 1, 2015, 7:20:41 PM4/1/15
to puppet...@googlegroups.com
Another thing to think on is adding a group to sudoers which covers your users needs, and then simply adding users to that group. By proxy, this also allows you to dump the users belonging to that group out to a facter for referencing and reporting.

Brian
Reply all
Reply to author
Forward
0 new messages