Adding multiple sudoer files to sudoers.d

933 views
Skip to first unread message

takrishnan

unread,
Apr 29, 2011, 12:53:14 PM4/29/11
to Puppet Users
I would like add multiple sudoer files to the sudoers.d directory and
would like someone to help.

I'm thinking something like should work but it's no.

init.pp
---------
class sudoers {
file:
:
:
pkg:
:
:
}

class sudoers::$sudogroup {
file {"$dirpath/$sudogroup":
path => "$dirpath/$sudogroup",
source => "puppet:///modules/sudoers/sudoers.d/
$sudogroup",
require => "File[/etc/sudoers.d]";
}
}

site.pp
---------

node sudonode {
include sudoers::group1
include sudoers::groups2
:
:
}

Is this possible?

Nan Liu

unread,
Apr 29, 2011, 1:04:02 PM4/29/11
to puppet...@googlegroups.com
On Fri, Apr 29, 2011 at 9:53 AM, takrishnan <takri...@yahoo.com> wrote:
> I would like add multiple sudoer files to the sudoers.d directory and
> would like someone to help.
>
> I'm thinking something like should work but it's no.
>
> init.pp
> ---------
> class sudoers {
>       file:
>        :
>        :
>       pkg:
>        :
>        :
> }
>
> class sudoers::$sudogroup {
>        file {"$dirpath/$sudogroup":
>                path => "$dirpath/$sudogroup",
>                source => "puppet:///modules/sudoers/sudoers.d/
> $sudogroup",
>                require => "File[/etc/sudoers.d]";
>        }
> }

What you are looking for is a define resource instead of a class.

define sudoers::config {
file { "/path/to/sudoers.d/${name}:
source => "puppet:///modules/sudoers/sudoers.d/${name}",
}
}

The require File[/etc/sudoers.d] should not be necessary, since it's
an implied dependency (puppet knows it's a file under that directory,
and you can find all implied dependency using --graph). You can use
the define like it's any standard resource:

sudoers::config { "group1": }
sudoers::config { "group2": }
...

Thanks,

Nan

takrishnan

unread,
May 4, 2011, 12:24:55 PM5/4/11
to Puppet Users
Thanks Nan!

Can I use the define directly within a node specification?
For example:

node abc {
include sudoers::config {"group1":}
}
node xyz inherits abc {
include sudoers::config {"group2":}
}

Anandha

On Apr 29, 10:04 am, Nan Liu <n...@puppetlabs.com> wrote:

Nan Liu

unread,
May 4, 2011, 11:47:00 PM5/4/11
to puppet...@googlegroups.com
On Wed, May 4, 2011 at 12:24 PM, takrishnan <takri...@yahoo.com> wrote:
> Can I use the define directly within a node specification?
> For example:
>
> node abc {
>      include sudoers::config {"group1":}
> }

Defines result in a custom resource type, and the sytax is the same as
any other puppet resource:
type { 'title':
attribute => value,
}

In your example above simply:
node abc {
    sudoers::config { "group1":
}
}

Thanks,

Nan

Reply all
Reply to author
Forward
0 new messages