Dan McManus
2013-Feb-07 22:04 UTC
[Puppet Users] I can''t get a custom fact to work in Windows
Hello all! I am using open source puppet 3.0.1 on both the client and master. The issue I am having is that I cannot get a simple custom fact to be recognized in my manifest. Hopefully I am missing something. I am trying to have a custom fact that will tell me whether the nsclient++ directory exists or not. Here''s the custom fact, which is located at /etc/puppet/environments/windows/modules/nscp-test/lib/facter Facter.add(:nsclient) do setcode do if File.exists?("c:/program files/nsclient++") puts ''''nsclient installed'' else puts ''no such directory'' end end end my init.pp is dead simple: class nscp-test { notify{$nsclient :} } Here''s what happens when I run puppet agent --test on the client (windows 2003): C:\Documents and Settings\All Users\Application Data\PuppetLabs\puppet\var\lib\facter>puppet agent --test Info: Retrieving plugin Info: Loading facts in C:/Documents and Settings/All Users/Application Data/PuppetLabs/puppet/var/lib/facter/nsclient.rb no such directory no such directory Info: Caching catalog for <snipped> Info: Applying configuration version ''1360274145'' Notice: undef Notice: /Stage[main]/Nscp-test/Notify[undef]/message: defined ''message'' as ''undef'' Notice: Finished catalog run in 0.42 seconds from the command line, facter --puppet nsclient works just fine. So am I missing something dead simple, or what? This is my first time doing custom facts. Thanks, Dan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Justin Stoller
2013-Feb-07 22:28 UTC
Re: [Puppet Users] I can''t get a custom fact to work in Windows
On Thu, Feb 7, 2013 at 2:04 PM, Dan McManus <mothbitten1@gmail.com> wrote:> Hello all! > > I am using open source puppet 3.0.1 on both the client and master. The > issue I am having is that I cannot get a simple custom fact to be > recognized in my manifest. Hopefully I am missing something. > > I am trying to have a custom fact that will tell me whether the nsclient++ > directory exists or not. > Here''s the custom fact, which is located at > /etc/puppet/environments/windows/modules/nscp-test/lib/facter > > Facter.add(:nsclient) do > setcode do > if File.exists?("c:/program files/nsclient++") > puts ''''nsclient installed'' > else > puts ''no such directory'' > >`puts` sends the string to stdout, you want to return the string. Ruby will implicitly return the last statement in a block. Which is how the examples in http://docs.puppetlabs.com/guides/custom_facts.html works. HTH, Justin end> end > end > > > my init.pp is dead simple: > > class nscp-test { > notify{$nsclient :} > } > > > Here''s what happens when I run puppet agent --test on the client (windows > 2003): > > C:\Documents and Settings\All Users\Application > Data\PuppetLabs\puppet\var\lib\facter>puppet agent --test > Info: Retrieving plugin > Info: Loading facts in C:/Documents and Settings/All Users/Application > Data/PuppetLabs/puppet/var/lib/facter/nsclient.rb > no such directory > no such directory > Info: Caching catalog for <snipped> > Info: Applying configuration version ''1360274145'' > Notice: undef > Notice: /Stage[main]/Nscp-test/Notify[undef]/message: defined ''message'' as > ''undef'' > Notice: Finished catalog run in 0.42 seconds > > > from the command line, facter --puppet nsclient works just fine. > > So am I missing something dead simple, or what? This is my first time > doing custom facts. > > Thanks, > > Dan > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Dan McManus
2013-Feb-07 22:39 UTC
Re: [Puppet Users] I can''t get a custom fact to work in Windows
Hah, yet, just removing the "puts" worked. Many thanks. On Thu, Feb 7, 2013 at 3:28 PM, Justin Stoller <justin@puppetlabs.com>wrote:> > > > On Thu, Feb 7, 2013 at 2:04 PM, Dan McManus <mothbitten1@gmail.com> wrote: > >> Hello all! >> >> I am using open source puppet 3.0.1 on both the client and master. The >> issue I am having is that I cannot get a simple custom fact to be >> recognized in my manifest. Hopefully I am missing something. >> >> I am trying to have a custom fact that will tell me whether the >> nsclient++ directory exists or not. >> Here''s the custom fact, which is located at >> /etc/puppet/environments/windows/modules/nscp-test/lib/facter >> >> Facter.add(:nsclient) do >> setcode do >> if File.exists?("c:/program files/nsclient++") >> puts ''''nsclient installed'' >> else >> puts ''no such directory'' >> >> > `puts` sends the string to stdout, you want to return the string. Ruby > will implicitly return the last statement in a block. Which is how the > examples in http://docs.puppetlabs.com/guides/custom_facts.html works. > > HTH, > Justin > > end >> end >> end >> >> >> my init.pp is dead simple: >> >> class nscp-test { >> notify{$nsclient :} >> } >> >> >> Here''s what happens when I run puppet agent --test on the client (windows >> 2003): >> >> C:\Documents and Settings\All Users\Application >> Data\PuppetLabs\puppet\var\lib\facter>puppet agent --test >> Info: Retrieving plugin >> Info: Loading facts in C:/Documents and Settings/All Users/Application >> Data/PuppetLabs/puppet/var/lib/facter/nsclient.rb >> no such directory >> no such directory >> Info: Caching catalog for <snipped> >> Info: Applying configuration version ''1360274145'' >> Notice: undef >> Notice: /Stage[main]/Nscp-test/Notify[undef]/message: defined ''message'' >> as ''undef'' >> Notice: Finished catalog run in 0.42 seconds >> >> >> from the command line, facter --puppet nsclient works just fine. >> >> So am I missing something dead simple, or what? This is my first time >> doing custom facts. >> >> Thanks, >> >> Dan >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Note that you can also use Puppet.notice to help debug and such. Adam On Thursday, February 7, 2013 4:39:42 PM UTC-6, Dan McManus wrote:> > Hah, yet, just removing the "puts" worked. Many thanks. > > On Thu, Feb 7, 2013 at 3:28 PM, Justin Stoller <jus...@puppetlabs.com<javascript:> > > wrote: > >> >> >> >> On Thu, Feb 7, 2013 at 2:04 PM, Dan McManus <mothb...@gmail.com<javascript:> >> > wrote: >> >>> Hello all! >>> >>> I am using open source puppet 3.0.1 on both the client and master. The >>> issue I am having is that I cannot get a simple custom fact to be >>> recognized in my manifest. Hopefully I am missing something. >>> >>> I am trying to have a custom fact that will tell me whether the >>> nsclient++ directory exists or not. >>> Here''s the custom fact, which is located at >>> /etc/puppet/environments/windows/modules/nscp-test/lib/facter >>> >>> Facter.add(:nsclient) do >>> setcode do >>> if File.exists?("c:/program files/nsclient++") >>> puts ''''nsclient installed'' >>> else >>> puts ''no such directory'' >>> >>> >> `puts` sends the string to stdout, you want to return the string. Ruby >> will implicitly return the last statement in a block. Which is how the >> examples in http://docs.puppetlabs.com/guides/custom_facts.html works. >> >> HTH, >> Justin >> >> end >>> end >>> end >>> >>> >>> my init.pp is dead simple: >>> >>> class nscp-test { >>> notify{$nsclient :} >>> } >>> >>> >>> Here''s what happens when I run puppet agent --test on the client >>> (windows 2003): >>> >>> C:\Documents and Settings\All Users\Application >>> Data\PuppetLabs\puppet\var\lib\facter>puppet agent --test >>> Info: Retrieving plugin >>> Info: Loading facts in C:/Documents and Settings/All Users/Application >>> Data/PuppetLabs/puppet/var/lib/facter/nsclient.rb >>> no such directory >>> no such directory >>> Info: Caching catalog for <snipped> >>> Info: Applying configuration version ''1360274145'' >>> Notice: undef >>> Notice: /Stage[main]/Nscp-test/Notify[undef]/message: defined ''message'' >>> as ''undef'' >>> Notice: Finished catalog run in 0.42 seconds >>> >>> >>> from the command line, facter --puppet nsclient works just fine. >>> >>> So am I missing something dead simple, or what? This is my first time >>> doing custom facts. >>> >>> Thanks, >>> >>> Dan >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Puppet Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to puppet-users...@googlegroups.com <javascript:>. >>> To post to this group, send email to puppet...@googlegroups.com<javascript:> >>> . >>> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users...@googlegroups.com <javascript:>. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.