On Feb 6, 4:23 pm, Gmoney <greg.caldwe...@gmail.com> wrote:
> I am using puppet 2.6.11 and want to pass parameter for implementing
> sudo for mulitple users. So here is my simple code, which I would like
> to pass to hiera to specify user name lookup. Appreciate any help,
> thanks in advance.
>
> class sudo( $name) {
> #Class:: sudo
> #
> #
>
> package { "sudo": ensure => present, }
>
> file { "/etc/sudoers":
>     owner   => root,
>     group   => root,
>     mode    => 440,
>     source  => "puppet:///modules/sudo/sudoers.$name",
>   }
>
> }   # Class:: sudo
>
> Hiera FIle for node :
>
> hostname01.yaml
> =============
>
> ---
> config:  - XXXX
> server:  - hostname01p
> node_classes: - sudo('webapp')
>
> I get this error message when trying to apply on node:
>
> puppet agent -tv --noop
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: Invalid tag "sudo('webapp')" at /etc/puppet/manifests/site.pp:
> 19 on node
>
> cat /etc/puppet/manifests/site.pp ( portion of file )
> ===================================
>
> node default {
>
>    hiera_include( "node_classes" )       # Maintained in hostgroups/
> <hostgroup>/<site>/<hostname>.yaml
>
> }


One of the strong points of using external data is the ability to
*avoid* using parameterized classes, which is a Good Thing to do.
External data solve all the same technical problems that class
parameters do, without incurring the costs that attend parameterizing
a class (such as the one you encountered).

Gary suggested one way to sidestep the particular parameterization
pitfall that tripped you up, but it woul be better to instead remove
the $name parameter from class sudo altogether.  Instead, just have
that class look up the appropriate name via hiera.  That leaves you
with *two* hiera lookups in your case:

1) The node looks up which classes to include
2) Class 'sudo' looks up the name(s) to use

There is then no need to create a new *params class, it works for any
sudo name (as does Gary's), and there is no problem with the sudo
class being included again from some other point, whether directly or
via hiera_include.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@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