Hi I have been having issue with deploying my custom facts. I have gone through wiki on puppet labs and few other blogs but has no luck so far. May be i am not understanding puppet very well. I would really appreciate if someone helps me with this. I have the following fact i want to deploy. Facter.add("curtime") do setcode do %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then echo "true"; fi } end end I have created following directory structure /etc/puppet/modules/common /etc/puppet/modules/common/lib/facter/curtime.rb /etc/puppet/modules/common/files /etc/puppet/modules/common/manifests/init.pp <- this file is empty on the puppet server i added the following to the /etc/puppet/ puppet.conf pluginsync = true modulepath = /etc/puppet/modules factpath = $vardir/facts on the client i have added factsync = true to the puppet.conf When i run puppetd on client i can''t see the new fact curtime also on the server i should be able to see the curtime fact under /var/lib/ puppet/facts. I am running puppetmasterd and client - 0.25.4 Any help would be appreciated. Thank you Brijesh -- 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.
On Jun 29, 2011, at 1:16 AM, brijesh wrote:> Hi > > I have been having issue with deploying my custom facts. I have gone > through wiki on puppet labs and few other blogs but has no luck so > far. May be i am not understanding puppet very well. I would really > appreciate if someone helps me with this. I have the following fact i > want to deploy. > > Facter.add("curtime") do > setcode do > %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then > echo "true"; fi } > end > end > > I have created following directory structure > > /etc/puppet/modules/common > /etc/puppet/modules/common/lib/facter/curtime.rb > /etc/puppet/modules/common/files > /etc/puppet/modules/common/manifests/init.pp <- this file is empty > > on the puppet server i added the following to the /etc/puppet/ > puppet.conf > > pluginsync = true > modulepath = /etc/puppet/modules > factpath = $vardir/facts > > on the client i have added > factsync = true to the puppet.conf > > When i run puppetd on client i can''t see the new fact curtime also on > the server i should be able to see the curtime fact under /var/lib/ > puppet/facts. > > I am running puppetmasterd and client - 0.25.4 > > Any help would be appreciated.---- 1 - Suggest that you use ruby language instead of trying to do things in shell 2 - Suggest that you use ''irb'' to troubleshoot ruby language segments for example... irb(main):002:0> foo = `date +%k` => " 8\n" irb(main):003:0> foo = (`date +%k`).chomp => " 8" irb(main):004:0> if foo <= 6 then foo -= 6 irb(main):005:1> foo irb(main):006:1> end ArgumentError: comparison of String with 6 failed from (irb):4:in `<='' from (irb):4 from :0 irb(main):008:0> foo => " 8" irb(main):009:0> foo = foo.to_i => 8 irb(main):010:0> foo <= 6 ? foo : foo -= 6 => 2 Hope this helps Craig -- 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.
On Jun 29, 2011, at 1:16 AM, brijesh wrote:> Hi > > I have been having issue with deploying my custom facts. I have gone > through wiki on puppet labs and few other blogs but has no luck so > far. May be i am not understanding puppet very well. I would really > appreciate if someone helps me with this. I have the following fact i > want to deploy. > > Facter.add("curtime") do > setcode do > %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then > echo "true"; fi } > end > end > > I have created following directory structure > > /etc/puppet/modules/common > /etc/puppet/modules/common/lib/facter/curtime.rb > /etc/puppet/modules/common/files > /etc/puppet/modules/common/manifests/init.pp <- this file is empty > > on the puppet server i added the following to the /etc/puppet/ > puppet.conf > > pluginsync = true > modulepath = /etc/puppet/modules > factpath = $vardir/facts > > on the client i have added > factsync = true to the puppet.conf > > When i run puppetd on client i can''t see the new fact curtime also on > the server i should be able to see the curtime fact under /var/lib/ > puppet/facts. > > I am running puppetmasterd and client - 0.25.4 > > Any help would be appreciated.---- If your custom fact has any errors, the fact will never work. You don''t have to go searching for ''facts'' - on any particular machine you should be able to just run from cli... facter (NAME OF FACT) - i.e. facter curtime I also neglected to mention that there really is no reason whatsoever to resort to shell just to do date things because ruby has a very rich ''Date'' class built-in. irb(main):001:0> require ''date'' => true irb(main):002:0> d = Date.today => #<Date: 4911483/2,0,2299161> irb(main):003:0> y = d.wday => 3 irb(main):001:0> require ''date'' => true irb(main):002:0> d = Date.today => #<Date: 4911483/2,0,2299161> irb(main):003:0> y = d + 3 => #<Date: 4911489/2,0,2299161> irb(main):004:0> z = y.strftime("%m-%d-%Y") => "07-02-2011" Craig -- 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.
Hi Craig, Thanks for your reply. I understand your concern about using ruby code instead of shell but my question how can i deploy this custom fact. The code has no error if i copy this fact into /usr/lib/ruby/1.8/facter and then run facter curtime it returns the output. The only thing is how can deploy this fact to all the clients? On Jun 30, 4:52 am, Craig White <craig.wh...@ttiltd.com> wrote:> On Jun 29, 2011, at 1:16 AM, brijesh wrote: > > > > > Hi > > > I have been having issue with deploying my custom facts. I have gone > > through wiki on puppet labs and few other blogs but has no luck so > > far. May be i am not understanding puppet very well. I would really > > appreciate if someone helps me with this. I have the following fact i > > want to deploy. > > > Facter.add("curtime") do > > setcode do > > %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then > > echo "true"; fi } > > end > > end > > > I have created following directory structure > > > /etc/puppet/modules/common > > /etc/puppet/modules/common/lib/facter/curtime.rb > > /etc/puppet/modules/common/files > > /etc/puppet/modules/common/manifests/init.pp <- this file is empty > > > on the puppet server i added the following to the /etc/puppet/ > > puppet.conf > > > pluginsync = true > > modulepath = /etc/puppet/modules > > factpath = $vardir/facts > > > on the client i have added > > factsync = true to the puppet.conf > > > When i run puppetd on client i can''t see the new fact curtime also on > > the server i should be able to see the curtime fact under /var/lib/ > > puppet/facts. > > > I am running puppetmasterd and client - 0.25.4 > > > Any help would be appreciated. > > ---- > If your custom fact has any errors, the fact will never work. You don''t have to go searching for ''facts'' - on any particular machine you should be able to just run from cli... > > facter (NAME OF FACT) - i.e. facter curtime > > I also neglected to mention that there really is no reason whatsoever to resort to shell just to do date things because ruby has a very rich ''Date'' class built-in. > > irb(main):001:0> require ''date'' > => true > irb(main):002:0> d = Date.today > => #<Date: 4911483/2,0,2299161> > irb(main):003:0> y = d.wday > => 3 > > irb(main):001:0> require ''date'' > => true > irb(main):002:0> d = Date.today > => #<Date: 4911483/2,0,2299161> > irb(main):003:0> y = d + 3 > => #<Date: 4911489/2,0,2299161> > irb(main):004:0> z = y.strftime("%m-%d-%Y") > => "07-02-2011" > > Craig-- 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.
I don''t know about ''factsync'' on client ''puppet.conf on my puppet clients, having [main] ... pluginsync=true seems to run the custom facts automatically Craig On Jun 29, 2011, at 2:02 PM, brijesh wrote:> Hi Craig, > > Thanks for your reply. I understand your concern about using ruby code > instead of shell but my question how can i deploy this custom fact. > The code has no error if i copy this fact into > /usr/lib/ruby/1.8/facter and then run > facter curtime it returns the output. > > The only thing is how can deploy this fact to all the clients? > > > On Jun 30, 4:52 am, Craig White <craig.wh...@ttiltd.com> wrote: >> On Jun 29, 2011, at 1:16 AM, brijesh wrote: >> >> >> >>> Hi >> >>> I have been having issue with deploying my custom facts. I have gone >>> through wiki on puppet labs and few other blogs but has no luck so >>> far. May be i am not understanding puppet very well. I would really >>> appreciate if someone helps me with this. I have the following fact i >>> want to deploy. >> >>> Facter.add("curtime") do >>> setcode do >>> %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then >>> echo "true"; fi } >>> end >>> end >> >>> I have created following directory structure >> >>> /etc/puppet/modules/common >>> /etc/puppet/modules/common/lib/facter/curtime.rb >>> /etc/puppet/modules/common/files >>> /etc/puppet/modules/common/manifests/init.pp <- this file is empty >> >>> on the puppet server i added the following to the /etc/puppet/ >>> puppet.conf >> >>> pluginsync = true >>> modulepath = /etc/puppet/modules >>> factpath = $vardir/facts >> >>> on the client i have added >>> factsync = true to the puppet.conf >> >>> When i run puppetd on client i can''t see the new fact curtime also on >>> the server i should be able to see the curtime fact under /var/lib/ >>> puppet/facts. >> >>> I am running puppetmasterd and client - 0.25.4 >> >>> Any help would be appreciated. >> >> ---- >> If your custom fact has any errors, the fact will never work. You don''t have to go searching for ''facts'' - on any particular machine you should be able to just run from cli... >> >> facter (NAME OF FACT) - i.e. facter curtime >> >> I also neglected to mention that there really is no reason whatsoever to resort to shell just to do date things because ruby has a very rich ''Date'' class built-in. >> >> irb(main):001:0> require ''date'' >> => true >> irb(main):002:0> d = Date.today >> => #<Date: 4911483/2,0,2299161> >> irb(main):003:0> y = d.wday >> => 3 >> >> irb(main):001:0> require ''date'' >> => true >> irb(main):002:0> d = Date.today >> => #<Date: 4911483/2,0,2299161> >> irb(main):003:0> y = d + 3 >> => #<Date: 4911489/2,0,2299161> >> irb(main):004:0> z = y.strftime("%m-%d-%Y") >> => "07-02-2011" >> >> Craig > > -- > 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. >-- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com Need help communicating between generations at work to achieve your desired success? Let us help! -- 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.
Thank You Very Much Craig that worked. On Jun 30, 9:12 am, Craig White <craig.wh...@ttiltd.com> wrote:> I don''t know about ''factsync'' on client ''puppet.conf > > on my puppet clients, having > [main] > ... > pluginsync=true > > seems to run the custom facts automatically > > Craig > > On Jun 29, 2011, at 2:02 PM, brijesh wrote: > > > > > Hi Craig, > > > Thanks for your reply. I understand your concern about using ruby code > > instead of shell but my question how can i deploy this custom fact. > > The code has no error if i copy this fact into > > /usr/lib/ruby/1.8/facter and then run > > facter curtime it returns the output. > > > The only thing is how can deploy this fact to all the clients? > > > On Jun 30, 4:52 am, Craig White <craig.wh...@ttiltd.com> wrote: > >> On Jun 29, 2011, at 1:16 AM, brijesh wrote: > > >>> Hi > > >>> I have been having issue with deploying my custom facts. I have gone > >>> through wiki on puppet labs and few other blogs but has no luck so > >>> far. May be i am not understanding puppet very well. I would really > >>> appreciate if someone helps me with this. I have the following fact i > >>> want to deploy. > > >>> Facter.add("curtime") do > >>> setcode do > >>> %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then > >>> echo "true"; fi } > >>> end > >>> end > > >>> I have created following directory structure > > >>> /etc/puppet/modules/common > >>> /etc/puppet/modules/common/lib/facter/curtime.rb > >>> /etc/puppet/modules/common/files > >>> /etc/puppet/modules/common/manifests/init.pp <- this file is empty > > >>> on the puppet server i added the following to the /etc/puppet/ > >>> puppet.conf > > >>> pluginsync = true > >>> modulepath = /etc/puppet/modules > >>> factpath = $vardir/facts > > >>> on the client i have added > >>> factsync = true to the puppet.conf > > >>> When i run puppetd on client i can''t see the new fact curtime also on > >>> the server i should be able to see the curtime fact under /var/lib/ > >>> puppet/facts. > > >>> I am running puppetmasterd and client - 0.25.4 > > >>> Any help would be appreciated. > > >> ---- > >> If your custom fact has any errors, the fact will never work. You don''t have to go searching for ''facts'' - on any particular machine you should be able to just run from cli... > > >> facter (NAME OF FACT) - i.e. facter curtime > > >> I also neglected to mention that there really is no reason whatsoever to resort to shell just to do date things because ruby has a very rich ''Date'' class built-in. > > >> irb(main):001:0> require ''date'' > >> => true > >> irb(main):002:0> d = Date.today > >> => #<Date: 4911483/2,0,2299161> > >> irb(main):003:0> y = d.wday > >> => 3 > > >> irb(main):001:0> require ''date'' > >> => true > >> irb(main):002:0> d = Date.today > >> => #<Date: 4911483/2,0,2299161> > >> irb(main):003:0> y = d + 3 > >> => #<Date: 4911489/2,0,2299161> > >> irb(main):004:0> z = y.strftime("%m-%d-%Y") > >> => "07-02-2011" > > >> Craig > > > -- > > 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 athttp://groups.google.com/group/puppet-users?hl=en. > > -- > Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.wh...@ttiltd.com > 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~www.ttiassessments.com > > Need help communicating between generations at work to achieve your desired success? Let us help!-- 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.
I should reiterate that you should use the interactive ruby shell, irb to test your code to make sure that it runs within ruby. You really should be using ruby for everything that you possibly can. If you can learn bash programming then ruby should be a piece of cake and provide readability down the road and actually make it a lot more fun and bring sense to the coding and structure within puppet too. Craig On Jun 29, 2011, at 3:22 PM, brijesh wrote:> Thank You Very Much Craig > > that worked. > > > > On Jun 30, 9:12 am, Craig White <craig.wh...@ttiltd.com> wrote: >> I don''t know about ''factsync'' on client ''puppet.conf >> >> on my puppet clients, having >> [main] >> ... >> pluginsync=true >> >> seems to run the custom facts automatically >> >> Craig >> >> On Jun 29, 2011, at 2:02 PM, brijesh wrote: >> >> >> >>> Hi Craig, >> >>> Thanks for your reply. I understand your concern about using ruby code >>> instead of shell but my question how can i deploy this custom fact. >>> The code has no error if i copy this fact into >>> /usr/lib/ruby/1.8/facter and then run >>> facter curtime it returns the output. >> >>> The only thing is how can deploy this fact to all the clients? >> >>> On Jun 30, 4:52 am, Craig White <craig.wh...@ttiltd.com> wrote: >>>> On Jun 29, 2011, at 1:16 AM, brijesh wrote: >> >>>>> Hi >> >>>>> I have been having issue with deploying my custom facts. I have gone >>>>> through wiki on puppet labs and few other blogs but has no luck so >>>>> far. May be i am not understanding puppet very well. I would really >>>>> appreciate if someone helps me with this. I have the following fact i >>>>> want to deploy. >> >>>>> Facter.add("curtime") do >>>>> setcode do >>>>> %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then >>>>> echo "true"; fi } >>>>> end >>>>> end >> >>>>> I have created following directory structure >> >>>>> /etc/puppet/modules/common >>>>> /etc/puppet/modules/common/lib/facter/curtime.rb >>>>> /etc/puppet/modules/common/files >>>>> /etc/puppet/modules/common/manifests/init.pp <- this file is empty >> >>>>> on the puppet server i added the following to the /etc/puppet/ >>>>> puppet.conf >> >>>>> pluginsync = true >>>>> modulepath = /etc/puppet/modules >>>>> factpath = $vardir/facts >> >>>>> on the client i have added >>>>> factsync = true to the puppet.conf >> >>>>> When i run puppetd on client i can''t see the new fact curtime also on >>>>> the server i should be able to see the curtime fact under /var/lib/ >>>>> puppet/facts. >> >>>>> I am running puppetmasterd and client - 0.25.4 >> >>>>> Any help would be appreciated. >> >>>> ---- >>>> If your custom fact has any errors, the fact will never work. You don''t have to go searching for ''facts'' - on any particular machine you should be able to just run from cli... >> >>>> facter (NAME OF FACT) - i.e. facter curtime >> >>>> I also neglected to mention that there really is no reason whatsoever to resort to shell just to do date things because ruby has a very rich ''Date'' class built-in. >> >>>> irb(main):001:0> require ''date'' >>>> => true >>>> irb(main):002:0> d = Date.today >>>> => #<Date: 4911483/2,0,2299161> >>>> irb(main):003:0> y = d.wday >>>> => 3 >> >>>> irb(main):001:0> require ''date'' >>>> => true >>>> irb(main):002:0> d = Date.today >>>> => #<Date: 4911483/2,0,2299161> >>>> irb(main):003:0> y = d + 3 >>>> => #<Date: 4911489/2,0,2299161> >>>> irb(main):004:0> z = y.strftime("%m-%d-%Y") >>>> => "07-02-2011" >> >>>> Craig >>-- 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.
sure i am right now changing it from bash to ruby. Brijesh On Jun 30, 10:55 am, Craig White <craig.wh...@ttiltd.com> wrote:> I should reiterate that you should use the interactive ruby shell, irb to test your code to make sure that it runs within ruby. > > You really should be using ruby for everything that you possibly can. If you can learn bash programming then ruby should be a piece of cake and provide readability down the road and actually make it a lot more fun and bring sense to the coding and structure within puppet too. > > Craig > > On Jun 29, 2011, at 3:22 PM, brijesh wrote: > > > Thank You Very Much Craig > > > that worked. > > > On Jun 30, 9:12 am, Craig White <craig.wh...@ttiltd.com> wrote: > >> I don''t know about ''factsync'' on client ''puppet.conf > > >> on my puppet clients, having > >> [main] > >> ... > >> pluginsync=true > > >> seems to run the custom facts automatically > > >> Craig > > >> On Jun 29, 2011, at 2:02 PM, brijesh wrote: > > >>> Hi Craig, > > >>> Thanks for your reply. I understand your concern about using ruby code > >>> instead of shell but my question how can i deploy this custom fact. > >>> The code has no error if i copy this fact into > >>> /usr/lib/ruby/1.8/facter and then run > >>> facter curtime it returns the output. > > >>> The only thing is how can deploy this fact to all the clients? > > >>> On Jun 30, 4:52 am, Craig White <craig.wh...@ttiltd.com> wrote: > >>>> On Jun 29, 2011, at 1:16 AM, brijesh wrote: > > >>>>> Hi > > >>>>> I have been having issue with deploying my custom facts. I have gone > >>>>> through wiki on puppet labs and few other blogs but has no luck so > >>>>> far. May be i am not understanding puppet very well. I would really > >>>>> appreciate if someone helps me with this. I have the following fact i > >>>>> want to deploy. > > >>>>> Facter.add("curtime") do > >>>>> setcode do > >>>>> %x{ foo=`date +%k` ; if [ "$foo" -ge 00 -o "$foo" -le 06 ] ; then > >>>>> echo "true"; fi } > >>>>> end > >>>>> end > > >>>>> I have created following directory structure > > >>>>> /etc/puppet/modules/common > >>>>> /etc/puppet/modules/common/lib/facter/curtime.rb > >>>>> /etc/puppet/modules/common/files > >>>>> /etc/puppet/modules/common/manifests/init.pp <- this file is empty > > >>>>> on the puppet server i added the following to the /etc/puppet/ > >>>>> puppet.conf > > >>>>> pluginsync = true > >>>>> modulepath = /etc/puppet/modules > >>>>> factpath = $vardir/facts > > >>>>> on the client i have added > >>>>> factsync = true to the puppet.conf > > >>>>> When i run puppetd on client i can''t see the new fact curtime also on > >>>>> the server i should be able to see the curtime fact under /var/lib/ > >>>>> puppet/facts. > > >>>>> I am running puppetmasterd and client - 0.25.4 > > >>>>> Any help would be appreciated. > > >>>> ---- > >>>> If your custom fact has any errors, the fact will never work. You don''t have to go searching for ''facts'' - on any particular machine you should be able to just run from cli... > > >>>> facter (NAME OF FACT) - i.e. facter curtime > > >>>> I also neglected to mention that there really is no reason whatsoever to resort to shell just to do date things because ruby has a very rich ''Date'' class built-in. > > >>>> irb(main):001:0> require ''date'' > >>>> => true > >>>> irb(main):002:0> d = Date.today > >>>> => #<Date: 4911483/2,0,2299161> > >>>> irb(main):003:0> y = d.wday > >>>> => 3 > > >>>> irb(main):001:0> require ''date'' > >>>> => true > >>>> irb(main):002:0> d = Date.today > >>>> => #<Date: 4911483/2,0,2299161> > >>>> irb(main):003:0> y = d + 3 > >>>> => #<Date: 4911489/2,0,2299161> > >>>> irb(main):004:0> z = y.strftime("%m-%d-%Y") > >>>> => "07-02-2011" > > >>>> Craig-- 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.