I am trying to read a variable that is within a file and make it a new
''fact''.
This does not seem to be working at all. Results below.
Is there a better way to do this?
nodes.pp
------------
node ''puppet-client'' {
include test
}
classes/test.pp
-------------------
class test {
exec { "testvar":
path => "/bin:/usr/bin",
command => "export FACTER_testvar=$(grep val /tmp/
tfile1)"
}
case $testvar {
val1: { notice("found val1") }
val2: { notice("found val2") }
default: { fail("found nothing") }
}
}
puppet-client/tmp/tfile1
------------------------------
blah
val1
blee
RESULTS
-----------
[root@puppet-client ~]# puppetd -t
notice: Ignoring cache
err: Could not retrieve catalog: found nothing at /etc/puppet/
manifests/classes/test.pp:10 on node puppet-client
warning: Not using cache on failed catalog
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
typedeaf
2008-May-05 20:34 UTC
[Puppet Users] Re: Using exec to create facts is not working
Can''t get generate to work properly either:
Server
--------
class test {
$testvar = generate("/bin/grep", "val",
"/tmp/tfile1")
case $testvar {
val1: { notice("found val1") }
val2: { notice("found val2") }
default: { fail("found nothing") }
}
}
Client
-------
[root@puppet-client ~]# /bin/grep val /tmp/tfile1
val1
[root@puppet-client ~]# puppetd -t
notice: Ignoring cache
err: Could not retrieve catalog: found nothing at /etc/puppet/
manifests/classes/test.pp:8 on node puppet-client
warning: Not using cache on failed catalog
Any ideas?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Peter Meier
2008-May-05 20:37 UTC
[Puppet Users] Re: Using exec to create facts is not working
Hi> I am trying to read a variable that is within a file and make it a new > ''fact''. > This does not seem to be working at all. Results below. > Is there a better way to do this?I don''t know from where the hell you have this way or why you do it that complicated. Ever tried: http://reductivelabs.com/trac/puppet/wiki/AddingFacts ??? greets pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Luke Kanies
2008-May-05 21:08 UTC
[Puppet Users] Re: Using exec to create facts is not working
On May 5, 2008, at 3:24 PM, typedeaf wrote:> I am trying to read a variable that is within a file and make it a new > ''fact''. > This does not seem to be working at all. Results below. > Is there a better way to do this?As Pete said, use custom facts. You can''t generate facts in the same run as you use them without following the directions at AddingFacts -- clients determine their fact list before the server ever starts compiling. -- Progress isn''t made by early risers. It''s made by lazy men trying to find easier ways to do something. --Robert Heinlein --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
typedeaf
2008-May-05 22:54 UTC
[Puppet Users] Re: Using exec to create facts is not working
Thanks. When testing my fact as stated in the link posted, I get the
following error:
[root@puppet-n1 manifests]# facter datacenter
/root/lib/ruby/facter: Is a directory - /root/lib/ruby/facter
(Errno::EISDIR)
from /usr/bin/facter:16:in `load''
from /usr/bin/facter:16
I did "mkdir -p ~/lib/ruby/facter; export RUBYLIB=~/lib/ruby" and then
copied the facter to the directory.
typedeaF
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
typedeaf
2008-May-13 16:41 UTC
[Puppet Users] Re: Using exec to create facts is not working
Got the custom fact working, however it does not work from the CLI using facter as http://reductivelabs.com/trac/puppet/wiki/AddingFacts describes. I used the "custom" module as described here http://reductivelabs.com/trac/puppet/wiki/PluginsInModules tF --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---