filsdepatrick
2011-Jul-07 20:00 UTC
[Puppet Users] Custom fact does not show up in puppet run
I am trying to make my first custom fact work following (I think) the instructions given on puppetlabs.com and in ''Pro Puppet''. Although I can evaluate my fact using facter from the cli, it doesn''t expand the fact from the variable name in my manifest. The os, puppet version and facter version are the same on both my client and the server: [root@vm-ops001-1 facter]# facter -v 1.5.9 [root@vm-ops001-1 facter]# puppet --version 2.6.4 The factpath is default on both client and server, and pluginsync is set to true in the [main] section of puppet.conf on both client and server. [root@vm-ops001-1 facter]# puppet --genconfig | grep -E ''factpath| pluginsync'' factpath = /var/lib/puppet/lib/facter:/var/lib/puppet/facts pluginsync = true my fact is defined on the server in /etc/puppet/modules/spacewalk/lib/ facter/activationKey.rb: [root@puppet ~]# cat /etc/puppet/modules/spacewalk/lib/facter/ activationKey.rb # activationKey.rb Facter.add(:activationKey) do setcode do "1-rhel5-x86_64" end end I trivialized it to test if I could eliminate the error (before it was using some core facts to derive activationKey), but the error is identical with the trivial fact. Here is how I attempt to reference my custom fact: [root@puppet ~]# cat /etc/puppet/modules/spacewalk/manifests/ register.pp class spacewalk::register { exec { ''register-with-spacewalk'': command => "rhnreg_ks --profilename=$hostname --activationkey$activationKey --serverUrl=http://spacewalk/XMLRPC", unless => "test -e /etc/sysconfig/rhn/systemid", path => [ ''/bin'', ''/sbin'', ''/usr/bin'', ''/usr/sbin'' ], require => Class[''spacewalk::install''], } } running the client with debug shows the exec command failing with an exit code of 255 which is consistent with the nul parameter for the -- activationkey option to rhnreg_ks. I''ve tried it multiple times in a row from the node with the identical result: [root@vm-ops001-1 ~]# puppetd -t --debug ... debug: Finishing transaction 23810158615960 debug: Storing state debug: Stored state in 0.01 seconds info: Loading facts in activationKey info: Loading facts in activationKey ... debug: Executing ''test -e /etc/sysconfig/rhn/systemid'' debug: /Stage[main]/Spacewalk::Register/Exec[register-with-spacewalk]: Executing ''rhnreg_ks --profilename=vm-ops001-1 --activationkey= -- serverUrl=http://spacewalk/XMLRPC'' debug: Executing ''rhnreg_ks --profilename=vm-ops001-1 --activationkey--serverUrl=http://spacewalk/XMLRPC'' err: /Stage[main]/Spacewalk::Register/Exec[register-with-spacewalk]/ returns: change from notrun to 0 failed: rhnreg_ks --profilename=vm- ops001-1 --activationkey= --serverUrl=http://spacewalk/XMLRPC returned 255 instead of one of [0] at /etc/puppet/modules/spacewalk/manifests/ register.pp:11 debug: Finishing transaction 23810158492340 debug: Storing state debug: Stored state in 0.01 seconds notice: Finished catalog run in 0.84 seconds The debug shows nothing expanded for the value of $activationKey from the register.pp manifest, running from cli works however with $FACTERLIB set: [root@vm-ops001-1 ~]# echo $FACTERLIB /var/lib/puppet/lib [root@vm-ops001-1 ~]# facter activationKey 1-rhel5-x86_64 Other things I''ve tried: restarting the master (server and agent) after each modification. putting activationKey.rb in /usr/lib/ruby/site-ruby/1.8/facter with the core facts (still same error). upgrading from facter 1.5.8 to facter 1.5.9 installing rubygems and deps which were not installed before. I''m really banging my head against the wall with this one, and I''m wondering if it''s something really obvious and stupid that I''ve overlooked. Any help would be greatly appreciated. thanks, Paul -- 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.
Paul Fitzpatrick
2011-Jul-07 20:53 UTC
[Puppet Users] Re: Custom fact does not show up in puppet run
I discovered by running facter without args on my client, that the fact shows up as ''activationkey'' (all lower case), even though I define it as ''activationKey'' in my .rb file. If I reference it as $activationkey in my manifest, it works as desired. It must be something about the way that facter parses the fact names, or a ruby constraint on variable names, although I couldn''t find it in the documentation. Anyway, it''s working now and I hope this helps someone else with the same issue. Paul On Thu, Jul 7, 2011 at 1:00 PM, filsdepatrick <filsdepatrick@gmail.com>wrote:> I am trying to make my first custom fact work following (I think) the > instructions given on puppetlabs.com and in ''Pro Puppet''. > > Although I can evaluate my fact using facter from the cli, it doesn''t > expand the fact from the variable name in my manifest. > > The os, puppet version and facter version are the same on both my > client and the server: > > [root@vm-ops001-1 facter]# facter -v > 1.5.9 > > [root@vm-ops001-1 facter]# puppet --version > 2.6.4 > > The factpath is default on both client and server, and pluginsync is > set to true in the [main] section of puppet.conf on both client and > server. > > [root@vm-ops001-1 facter]# puppet --genconfig | grep -E ''factpath| > pluginsync'' > factpath = /var/lib/puppet/lib/facter:/var/lib/puppet/facts > pluginsync = true > > > my fact is defined on the server in /etc/puppet/modules/spacewalk/lib/ > facter/activationKey.rb: > > [root@puppet ~]# cat /etc/puppet/modules/spacewalk/lib/facter/ > activationKey.rb > # activationKey.rb > > Facter.add(:activationKey) do > setcode do > "1-rhel5-x86_64" > end > end > > I trivialized it to test if I could eliminate the error (before it was > using some core facts to derive activationKey), but the error is > identical with the trivial fact. > > Here is how I attempt to reference my custom fact: > > [root@puppet ~]# cat /etc/puppet/modules/spacewalk/manifests/ > register.pp > > class spacewalk::register { > > > > exec { ''register-with-spacewalk'': > command => "rhnreg_ks --profilename=$hostname --activationkey> $activationKey --serverUrl=http://spacewalk/XMLRPC", > unless => "test -e /etc/sysconfig/rhn/systemid", > path => [ ''/bin'', ''/sbin'', ''/usr/bin'', ''/usr/sbin'' ], > require => Class[''spacewalk::install''], > } > > } > > running the client with debug shows the exec command failing with an > exit code of 255 which is consistent with the nul parameter for the -- > activationkey option to rhnreg_ks. I''ve tried it multiple times in a > row from the node with the identical result: > > [root@vm-ops001-1 ~]# puppetd -t --debug > > ... > debug: Finishing transaction 23810158615960 > debug: Storing state > debug: Stored state in 0.01 seconds > info: Loading facts in activationKey > info: Loading facts in activationKey > ... > > debug: Executing ''test -e /etc/sysconfig/rhn/systemid'' > debug: /Stage[main]/Spacewalk::Register/Exec[register-with-spacewalk]: > Executing ''rhnreg_ks --profilename=vm-ops001-1 --activationkey= -- > serverUrl=http://spacewalk/XMLRPC'' > debug: Executing ''rhnreg_ks --profilename=vm-ops001-1 --activationkey> --serverUrl=http://spacewalk/XMLRPC'' > err: /Stage[main]/Spacewalk::Register/Exec[register-with-spacewalk]/ > returns: change from notrun to 0 failed: rhnreg_ks --profilename=vm- > ops001-1 --activationkey= --serverUrl=http://spacewalk/XMLRPC returned > 255 instead of one of [0] at /etc/puppet/modules/spacewalk/manifests/ > register.pp:11 > debug: Finishing transaction 23810158492340 > debug: Storing state > debug: Stored state in 0.01 seconds > notice: Finished catalog run in 0.84 seconds > > The debug shows nothing expanded for the value of $activationKey from > the register.pp manifest, running from cli works however with > $FACTERLIB set: > > > [root@vm-ops001-1 ~]# echo $FACTERLIB > /var/lib/puppet/lib > [root@vm-ops001-1 ~]# facter activationKey > 1-rhel5-x86_64 > > Other things I''ve tried: > > restarting the master (server and agent) after each modification. > > putting activationKey.rb in /usr/lib/ruby/site-ruby/1.8/facter with > the core facts (still same error). > > upgrading from facter 1.5.8 to facter 1.5.9 > > installing rubygems and deps which were not installed before. > > I''m really banging my head against the wall with this one, and I''m > wondering if it''s something really obvious and stupid that I''ve > overlooked. Any help would be greatly appreciated. > > thanks, > > Paul-- 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.