No, you don't have access to resource namevar unless it's within the
defined resource.
> 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
FWIW: It doesnt reference the environment variable directly. It references the
fact "path" which in turn is the path environment variable.
Just run »facter path« on the command line and you should get similar
results.
-Stefan
On Wed, Aug 24, 2011 at 2:23 PM, jblaine <cjbl...@gmail.com> 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.
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
--
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/-/_E4djfGmFHEJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Line 30 of your config.pp is where your problem lies (one of them anyway). It can't find the source file.
file { '/etc/nslcd.conf':
mode => '444',
source => "${ldapclient::params::fileroot}/${name}",
owner => $ldapclient::params::ldapclient_user,
require => Class['ldapclient::install'],
notify => Class['ldapclient::service'],
}
So it is interpreting this:
"${ldapclient::params::fileroot}/${name}",
As:
puppet:///modules/ldapclient/files/RH6/ldapclient::config
The following will give detail about fileserving, but $name is probably not resolving to what you think it should:
http://docs.puppetlabs.com/guides/file_serving.html
How are you declaring this in your manliest. What do you think $name should be? Try putting in the source path without the variable substitution.
Den
This is maddening. What do those errors even mean? So vague :(
--
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/-/ZwWSDMnrqesJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
But why?
> class ldapclient::config {
> case $sys_sshortai {
> 'RH6': {
> file { '/etc/openldap/ldap.conf':
> mode => '444',
> source => "${ldapclient::params::fileroot}/${name}",
You're back to square one. $name is nothing sensible in this context.
It's the name of the class this appears inside of - 'ldapclient::config'.
For automatic URL composition by use of the file path, you definitely do
want to wrap the file resource in a defined type like you were trying
earlier!
HTH,
Felix
On 01/28/2012 12:17 AM, jblaine wrote:
> Trashing the entire defined resource idea 30 mins ago, and
> simply trying:But why?
> class ldapclient::config {
> case $sys_sshortai {
> 'RH6': {
> file { '/etc/openldap/ldap.conf':
> mode => '444',
> source => "${ldapclient::params::fileroot}/${name}",You're back to square one. $name is nothing sensible in this context.
It's the name of the class this appears inside of - 'ldapclient::config'.
That's correct, yes.