saz / puppet-sudo

Manage sudo with Puppet on Debian-, RedHat- and SUSE-based linux distributions and some BSDs
Other
107 stars 215 forks source link

How can I add Cmnd_Alias #219

Closed glafir closed 6 years ago

glafir commented 6 years ago

Hellow! How can I add Cmnd_Alias in module for example in sudoers config:

Cmnd_Alias APACHE_START = /usr/bin/service apache2 start
Cmnd_Alias APACHE_STOP = /usr/bin/service apache2 stop
Cmnd_Alias APACHE_RESTART = /usr/bin/service apache2 restart
Cmnd_Alias APACHE_RELOAD = /usr/bin/service apache2 reload

I did this in yaml

  sudo::configs:
    configs_hash:
      cmd_alias:
        priority: 5
        content:
        - 'Cmnd_Alias APACHE_START = /usr/bin/service apache2 start'
        - 'Cmnd_Alias APACHE_STOP = /usr/bin/service apache2 stop'
        - 'Cmnd_Alias APACHE_RESTART = /usr/bin/service apache2 restart'
        - 'Cmnd_Alias APACHE_RELOAD = /usr/bin/service apache2 reload'

But it didn`t work (((

saz commented 6 years ago

There is no type for command aliasses. You have to pass the information to sudo::conf.

Using a file:

sudo::conf { 'web':
      source => 'puppet:///files/etc/sudoers.d/web',
    }

where file content is

Cmnd_Alias APACHE_START = /usr/bin/service apache2 start
Cmnd_Alias APACHE_STOP = /usr/bin/service apache2 stop
Cmnd_Alias APACHE_RESTART = /usr/bin/service apache2 restart
Cmnd_Alias APACHE_RELOAD = /usr/bin/service apache2 reload

# Any other sudo option which might fit in this file

or pass the values as content to sudo::conf