On Wednesday, August 24, 2011 6:38:21 PM UTC-4, Nan Liu wrote:
>
> On Wed, Aug 24, 2011 at 2:23 PM, jblaine <[email protected]> wrote:
> > 2.7.3
> > The heck?  ${path} is expanding to the shell environment PATH when I
> > reference it as a variable
> > in my file resource.  Isn't this supposed to be the "namevar" for file
> > resources?
>
> No, you don't have access to resource namevar unless it's within the
> defined resource.
>
Hi Nan,

Thanks for the reply (you too Stefan).

My reference to the resource's namevar *is within the defined resource*.

            file { [ '/etc/openldap/ldap.conf', '/etc/ldap.conf' ]:
                source => "${ldapclient::params::fileroot}${path}",
                owner => "$ldapclient::params::ldapclient_user",
                mode => 0444,
                require => Class['ldapclient::install'],
            }

>From what I've read of all the Puppet documentation I have (the latest
2 books (1 unreleased yet) + the Puppetlabs docs), the above should
work without having to "define" a custom resource as you show below.
Where am I wrong in my reading/thinking?  I must be missing something
somewhere.

--------------------------------------------------------------------------
http://docs.puppetlabs.com/references/stable/type.html#file

...
The namevar is the parameter used to uniquely identify a type instance. This 
is the parameter that gets assigned when a string is provided before the 
colon in a type declaration. In general, only developers will need to worry 
about which parameter is the namevar.
...
FILE
...
path
    namevar
The path to the file to manage. Must be fully qualified.
...
--------------------------------------------------------------------------
http://docs.puppetlabs.com/guides/language_guide.html#arrays

...
Example shown:

file { [ 'foo', 'bar', 'foobar' ]:
    owner => 'root',
    group => 'root',
    mode => '0600',
}
--------------------------------------------------------------------------

> err: /Stage[main]/Ldapclient::Config/File[/etc/ldap.conf]: Could not
> > evaluate: Could not retrieve information from environment production
> > source(s) 
> puppet:///modules/ldapclient/RedHat/usr/bin:/bin:/usr/sbin:/sbin
> > at /etc/puppet/modules/ldapclient/manifests/config.pp:9
> > class ldapclient::config {
> >     case $operatingsystem {
> >         /(RedHat|CentOS|Fedora)/: {
> >             file { [ '/etc/openldap/ldap.conf', '/etc/ldap.conf' ]:
> >                 source => "${ldapclient::params::fileroot}${path}",
> >                 owner => "$ldapclient::params::ldapclient_user",
> >                 mode => 0444,
> >                 require => Class['ldapclient::install'],
> >             }
> >         }
> >     }
> > }
>
> define ldapclient::conf {
>   file { $name:
>     source => ${ldapclient::params::fileroot}/${name},
>     owner  => $ldapclient::params::ldapclient_user,
>     mode => '0444',
>     require => Class['ldapclient::install'],
>   }
> }
>
> ldapclient::conf { [ '/etc/openldap/ldap.conf', '/etc/ldap.conf' ]: }
>
> Nan
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/BtEES_MEhzAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to