On Thu, Aug 25, 2011 at 07:44:46AM -0700, jblaine wrote: > 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'], > } >
You misunderstood the concept of a namevar. The namevar of the
file resource is `path`, for the exec resource it is `command`, for a
service resource it is `name` and so on.
Here is an example where I set the namevar.
file { 'sshconfig':
path => '/etc/ssh/sshd_config',
ensure => file,
mode => '0600',
}
So I set the namevar (path) explicitly. Note that `namevar` is more
from the viewpoint of a resource type developer. In a manifest it is
just a parameter of a resource.
If you do not specify the namevar explicitly, it is the text before the
first colon, so in other words the title of the resource.
So when I write
file { '/etc/ssh/sshd_config':
ensure => file,
mode => '0600',
}
I did not specify the path of the file directly. I just set the title
and so path is implicitly /etc/ssh/sshd_config in the example.
However you cannot access the path parameter as a variable in your
manifest. It just happened that there is a fact that is named `path` so
whenever you use $path you will just query that fact.
-Stefan
pgp84jATGwdiu.pgp
Description: PGP signature
