---------------------------------
$my_var1 = 'my 1st variable'
$my_var2 = 'my 2nd variable"
---------------------------------
in a file, e.g. called "settings.pp" and then try to accessing them
from another manifests after importing settings.pp, but that's
absolutely not working. I'm writing a costume module for our and group
and I want individual user only to edit the "settings.pp" to put their
own value to make this module work for them. How can I make that
happen? Cheers!!
----
presuming that you aren't using an ENC, you would probably want to simply put the variable in the node definition itself.
Craig
It's actually like: "modulepath/modules/mymodule/manifests/
settings.pp" and I was trying to use those variables in the other
manifests in "mymodule". I know that autoloader and "include" classes
are the way of doing these day but as nothing worked so far, so I
tried "import" method as well. I didn't try "$settings::my_var1" thing
yet but I'm giving it a shot now.
Cheers,
Santanu
Hi Nigel,
It's actually like: "modulepath/modules/mymodule/manifests/
settings.pp" and I was trying to use those variables in the other
manifests in "mymodule". I know that autoloader and "include" classes
are the way of doing these day but as nothing worked so far, so I
tried "import" method as well. I didn't try "$settings::my_var1" thing
yet but I'm giving it a shot now.
Cheers,
Santanu
>
> Assuming you did something like:
>
> # modulepath/modules/settings/manifests/init.pp
> class settings {
> $my_var1 = "myvar1"
>
> }
>
> and include the class "settings", from other classes you can refer to it as:
>
> $settings::my_var1
>
> Does that help?
>
> I noticed you used the word "import". The most frictionless way to use
> Puppet these days is to avoid import, and to instead structure your classes
> in modules, and use the autoloader and "include" classes rather than
> importing manifest files.
>
> --
> Nigel Kersten
> Product Manager, Puppet Labs
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
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.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
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.
I must be doing something really stupid - I still don't get it and and
trying to understand what I'm doing wrong. This is what I have so
far....
-------------------------------------------
# /modulepath/modules/zmfs/manifests/settings.pp:
class zmfs::settings {
$l_dir = '/zmfs/ldir.ac.uk'
.......
.......
}
# /modulepath/modules/zmfs/manifests/envcheck.pp:
class zmfs::envcheck {
define env_check($file, $string, $swdir, $refreshonly = 'true') {
......
......
}
}
# /modulepath/modules/zmfs/manifests/config.pp:
include zmfs::settings
include zmfs::envcheck
class zmfs::config {
env_check { vo_lhcb:
file => '/etc/profile.d/zfs-env.sh',
string => "$settings::l_dir",
.......
.......
}
}
-----------------------------------------------------------
But all I get an empty string on the target node. Is this what I'm
supposed to do? Or I'm still missing something? Cheers!!
Now the problem is: If I define "env_check" inside a
'class' (envcheck.pp in my example code above) and specify "include
zmfs::envcheck" in the config.pp, I get this error:
-------------------------
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError:
Invalid resource type line_check at /etc/puppet/modules/zmfs/manifests/
config.pp:94 on node farm002.. .. ..ac.uk
-------------------------
It only works if the envcheck.pp like this way:
------------------------
# /modulepath/modules/zmfs/manifests/envcheck.pp:
define env_check($file, $string, $swdir, $refreshonly = 'true') {
......
......
}
------------------------
(i.e. without having a class) and use "import envcheck.pp", instead
of: include zmfs::envcheck in the manifest. Does any one know what's
going wrong?
Cheers,
San
Thanks Nigel! That works like a charm. But leaves me with one question
and another problem. First the question: If I always need to specify
the varable like "$zmfs::settings::l_dir", then waht the significance
of the "include" statement (e.g. include zmfs::settings ) in the
beginning of the manifest?
Now the problem is: If I define "env_check" inside a
'class' (envcheck.pp in my example code above) and specify "include
zmfs::envcheck" in the config.pp, I get this error:
-------------------------
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError:
Invalid resource type line_check at /etc/puppet/modules/zmfs/manifests/
config.pp:94 on node farm002.. .. ..ac.uk
-------------------------
It only works if the envcheck.pp like this way:
------------------------
# /modulepath/modules/zmfs/manifests/envcheck.pp:
------------------------
define env_check($file, $string, $swdir, $refreshonly = 'true') {
......
......
}
(i.e. without having a class) and use "import envcheck.pp", instead
of: include zmfs::envcheck in the manifest. Does any one know what's
going wrong?
Cheers,
San
>
> You want to use $zmfs::settings::l_dir
>
> You're fully qualifying the variable, so you need the "full path" to it,
> including the name of the module it lives in.
>
> --
> Nigel Kersten
> Product Manager, Puppet Labs
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
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.