define sudoentry ($user, $host = "ALL", $command = "ALL", $tag
= "NOPASSWD", $runas = "ALL") {
                $sudo_changes = $tag ? {
                        false => [
                                "set spec[user = '$user']/user $user",
                                "set spec[user = '$user']/host_group/
host $host",
                                "set spec[user = '$user']/host_group/
command '$command'",
                                "remove spec[user = '$user']/
host_group/command/tag",
                                "set spec[user = '$user']/host_group/
command/runas_user $runas",
                        ],
                        # this isn't a real tag, but a sneaky hack to
remove entries
                        DELETE => "remove spec[user = '$user']",
                        default => [
                                "set spec[user = '$user']/user $user",
                                "set spec[user = '$user']/host_group/
host $host",
                                "set spec[user = '$user']/host_group/
command '$command'",
                                "set spec[user = '$user']/host_group/
command/tag $tag",
                                "set spec[user = '$user']/host_group/
command/runas_user $runas",
                        ],
                }
                augeas { "sudo-$name":
                        context => "/files/etc/sudoers",
                        changes => $sudo_changes,
                }
        }

        sudo::sudoentry { "centreon_sudoers1": user => "apache",
command => "/etc/init.d/nagios* restart" }
        sudo::sudoentry { "centreon_sudoers2": user => "apache",
command => "/etc/init.d/nagios* reload" }

On 19 ноя, 15:56, "luke.bigum" <luke.bi...@fasthosts.co.uk> wrote:
> Hi Walexey,
>
> Can you post the augeas resource that you've got so far?
>
> On Nov 19, 12:50 pm, walexey <wale...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello everybody!
> > How can i create with puppet following sudoers file:
>
> > User_Alias      CENTREON=apache,nagios
> > CENTREON   ALL = NOPASSWD: /etc/init.d/nagios* restart
> > CENTREON   ALL = NOPASSWD: /etc/init.d/nagios* reload
> > CENTREON   ALL = NOPASSWD: /usr/bin/nagios* -v *
>
> > The problem that augeas create only last line, replacing previous one.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to