Hello there I''m having a problem (again). At my site we are maintaining RHEL, CentOS and Solaris hosts, with in the future possibly some FreeBSD also being added into the mix. To this end instead of constantly branching whenever running a command on the console (or remembering where it is located), I''ve set all the commands we need so far up in the default node: class defaultnode { if ($httpd_group == "") { $httpd_group = "root" } case $operatingsystem { centos, redhat: { $cat_cmd = "/bin/cat" $chkconfig_cmd = "/sbin/chkconfig" $chown_cmd = "/bin/chown" $chmod_cmd = "/bin/chmod" $echo_cmd = "/bin/echo" $grep_cmd = "/bin/grep" $ln_cmd = "/bin/ln" $ls_cmd = "/bin/ls" $mailx_cmd = "/bin/mailx" $newaliases_cmd = "/usr/bin/newaliases" $rm_cmd = "/bin/rm" $sed_cmd = "/bin/sed" $tar_cmd = "/bin/tar" $touch_cmd = "/bin/touch" $wget_cmd = "/usr/bin/wget" include redhat-default } solaris: { $cat_cmd = "/usr/bin/cat" $chown_cmd = "/usr/bin/chown" $chmod_cmd = "/usr/bin/chmod" $echo_cmd = "/usr/bin/echo" $grep_cmd = "/usr/bin/grep" $mailx_cmd = "/usr/bin/mailx" $newaliases_cmd = "/usr/sbin/newaliases" $rm_cmd = "/usr/bin/rm" $tar_cmd = "/usr/sfw/bin/gtar" include solaris-default } default: { include shared-default } } } which is called by all nodes, eg: node "testnode.example.org" { include defaultnode exec { "$chkconfig_cmd snmpd on && $touch_cmd /tmp/ snmpd_chkconfig.USG": cwd => "/", creates => "/tmp/snmpd_chkconfig.USG", } } But when i run puppet the variables aren''t defined: err: Could not create snmpd on && /tmp/snmpd_chkconfig.USG: '' snmpd on && /tmp/snmpd_chkconfig.USG'' is both unqualifed and specified no search path at /etc/puppet/manifests/nodes/testnode.node:9 warning: Not using cache on failed catalog warning: Configuration could not be instantiated: '' snmpd on && /tmp/ snmpd_chkconfig.USG'' is both unqualifed and specified no search path at /etc/puppet/manifests/nodes/testnode.node:9 The thing is, it seems to work occasionally, on some hosts, but i can''t see the rhyme or reason behind this... --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
chakkerz wrote:> Hello there > > I''m having a problem (again). At my site we are maintaining RHEL, > CentOS and Solaris hosts, with in the future possibly some FreeBSD > also being added into the mix. To this end instead of constantly > branching whenever running a command on the console (or remembering > where it is located), I''ve set all the commands we need so far up in > the default node: > > class defaultnode > { > if ($httpd_group == "") > { > $httpd_group = "root" > } > > case $operatingsystem > { > centos, redhat: > { > $cat_cmd = "/bin/cat" > $chkconfig_cmd = "/sbin/chkconfig" > $chown_cmd = "/bin/chown" > $chmod_cmd = "/bin/chmod" > $echo_cmd = "/bin/echo" > $grep_cmd = "/bin/grep" > $ln_cmd = "/bin/ln" > $ls_cmd = "/bin/ls" > $mailx_cmd = "/bin/mailx" > $newaliases_cmd = "/usr/bin/newaliases" > $rm_cmd = "/bin/rm" > $sed_cmd = "/bin/sed" > $tar_cmd = "/bin/tar" > $touch_cmd = "/bin/touch" > $wget_cmd = "/usr/bin/wget" > > include redhat-default > } > solaris: > { > $cat_cmd = "/usr/bin/cat" > $chown_cmd = "/usr/bin/chown" > $chmod_cmd = "/usr/bin/chmod" > $echo_cmd = "/usr/bin/echo" > $grep_cmd = "/usr/bin/grep" > $mailx_cmd = "/usr/bin/mailx" > $newaliases_cmd = "/usr/sbin/newaliases" > $rm_cmd = "/usr/bin/rm" > $tar_cmd = "/usr/sfw/bin/gtar" > > include solaris-default > } > default: > { > include shared-default > } > } > } > > which is called by all nodes, eg: > > node "testnode.example.org" > { > include defaultnode > > exec > { "$chkconfig_cmd snmpd on && $touch_cmd /tmp/ > snmpd_chkconfig.USG": > cwd => "/", > creates => "/tmp/snmpd_chkconfig.USG", > } > > } > > But when i run puppet the variables aren''t defined: > err: Could not create snmpd on && /tmp/snmpd_chkconfig.USG: '' snmpd > on && /tmp/snmpd_chkconfig.USG'' is both unqualifed and specified no > search path at /etc/puppet/manifests/nodes/testnode.node:9 > warning: Not using cache on failed catalog > warning: Configuration could not be instantiated: '' snmpd on && /tmp/ > snmpd_chkconfig.USG'' is both unqualifed and specified no search path > at /etc/puppet/manifests/nodes/testnode.node:9Variables don''t escape their scope. Use the search() function to add "defaultnode" to the serachpath or reference the variables directly with $defaultnode::chkconfig_cmd or "${defaultnode::chkconfig_cmd}". See the LanguageTutorial on the wiki for details (section "Variables"[1]). Regards, DavidS [1] http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#variables --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt wrote:> chakkerz wrote: >> Hello there >> >> I''m having a problem (again). At my site we are maintaining RHEL, >> CentOS and Solaris hosts, with in the future possibly some FreeBSD >> also being added into the mix. To this end instead of constantly >> branching whenever running a command on the console (or remembering >> where it is located), I''ve set all the commands we need so far up in >> the default node: >> >> class defaultnode >> { >> if ($httpd_group == "") >> { >> $httpd_group = "root" >> } >> >> case $operatingsystem >> { >> centos, redhat: >> { >> $cat_cmd = "/bin/cat" >> $chkconfig_cmd = "/sbin/chkconfig" >> $chown_cmd = "/bin/chown" >> $chmod_cmd = "/bin/chmod" >> $echo_cmd = "/bin/echo" >> $grep_cmd = "/bin/grep" >> $ln_cmd = "/bin/ln" >> $ls_cmd = "/bin/ls" >> $mailx_cmd = "/bin/mailx" >> $newaliases_cmd = "/usr/bin/newaliases" >> $rm_cmd = "/bin/rm" >> $sed_cmd = "/bin/sed" >> $tar_cmd = "/bin/tar" >> $touch_cmd = "/bin/touch" >> $wget_cmd = "/usr/bin/wget" >> >> include redhat-default >> } >> solaris: >> { >> $cat_cmd = "/usr/bin/cat" >> $chown_cmd = "/usr/bin/chown" >> $chmod_cmd = "/usr/bin/chmod" >> $echo_cmd = "/usr/bin/echo" >> $grep_cmd = "/usr/bin/grep" >> $mailx_cmd = "/usr/bin/mailx" >> $newaliases_cmd = "/usr/sbin/newaliases" >> $rm_cmd = "/usr/bin/rm" >> $tar_cmd = "/usr/sfw/bin/gtar" >> >> include solaris-default >> } >> default: >> { >> include shared-default >> } >> } >> } >> >> which is called by all nodes, eg: >> >> node "testnode.example.org" >> { >> include defaultnode >> >> exec >> { "$chkconfig_cmd snmpd on && $touch_cmd /tmp/ >> snmpd_chkconfig.USG": >> cwd => "/", >> creates => "/tmp/snmpd_chkconfig.USG", >> } >> >> } >> >> But when i run puppet the variables aren''t defined: >> err: Could not create snmpd on && /tmp/snmpd_chkconfig.USG: '' snmpd >> on && /tmp/snmpd_chkconfig.USG'' is both unqualifed and specified no >> search path at /etc/puppet/manifests/nodes/testnode.node:9 >> warning: Not using cache on failed catalog >> warning: Configuration could not be instantiated: '' snmpd on && /tmp/ >> snmpd_chkconfig.USG'' is both unqualifed and specified no search path >> at /etc/puppet/manifests/nodes/testnode.node:9 > > Variables don''t escape their scope. Use the search() function to add > "defaultnode" to the serachpath or reference the variables directly with > $defaultnode::chkconfig_cmd or "${defaultnode::chkconfig_cmd}". See the > LanguageTutorial on the wiki for details (section "Variables"[1]).D''oh. For your actual, underlying problem it''d probably be better to use something like Volcane''s extlookup[1][2] function: | $extlookup_datadir = "/etc/puppet/manifests/extdata" | $extlookup_precedence = ["%{fqdn}", "os_%{operatingsystem}", "shared"] | $cat_cmd = extlookup(''cat_cmd'') That can be done in the top-level scope (e.g. in the site.pp outside of any node or class) to propagate the values to all manifests and modules. Regards, DavidS [1]http://nephilim.ml.org/~rip/puppet/extlookup.rb [2]http://github.com/puppet-modules/puppet-common/blob/0caa32db1aaad6dabc9542c5e0aa20e76ea94f48/plugins/puppet/parser/functions/extlookup.rb --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hello there David Actually, you had it at the first message :) and here is why i think that: the problem is that i can not guarantee the order of execution, so even if i define it at the top level, or more appropriately at the defaultnode level (why have two case statements ?) i still could not guarantee the statement will be evaluated at the right time. Whereas defining the scope at which the variable is set, i get around the issue entirely, because it forces the evaluation because puppet understands what i want. Regardless of the problem being caused by being in the wrong scope (unless of course it can not reach that scope) or because of order of evaluation. That said i could be wrong, but it does look like it is fixing my problem ... So, thank you :) chakkerz --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---