Dan White
2012-May-29 15:55 UTC
[Puppet Users] I did something stooopid in a custom fact and I do not know what
I''m a custom fact n00b :( ---broadcast.rb: #Return the broadcast address of eth0 require ''facter'' Facter.add("broadcast") do ipaddr = Facter.value(''ipaddress'') nmask = Facter.value(''netmask'') setcode do Facter::Util::Resolution.exec{"ipcalc -s -b #{ipaddr} #{nmask} | cut -d= -f2"} end end ...and when I run puppet apply, I get: Could not retrieve broadcast: wrong number of arguments (0 for 1) Puppet 2.7.12 ruby 1.8.7 (patchlevel 352) [x86_64-linux] “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) -- 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.
Gary Larizza
2012-May-29 16:07 UTC
Re: [Puppet Users] I did something stooopid in a custom fact and I do not know what
On Tue, May 29, 2012 at 8:55 AM, Dan White <ygor@comcast.net> wrote:> I''m a custom fact n00b :( > > ---broadcast.rb: > #Return the broadcast address of eth0 > require ''facter'' > > Facter.add("broadcast") do > ipaddr = Facter.value(''ipaddress'') > nmask = Facter.value(''netmask'') > setcode do > Facter::Util::Resolution.exec{"ipcalc -s -b #{ipaddr} #{nmask} | > cut -d= -f2"} >Try using parenthesis instead of curly braces in Facter::Util::Resolution.exec () You could ALSO do: setcode("ipcalc -s -b #{ipaddr} #{nmask} | cut -d-f2") Passing a string to setcode instead of a block pipes the command to Facter::Util::Resolution.exec() end> end > > ...and when I run puppet apply, I get: > > Could not retrieve broadcast: wrong number of arguments (0 for 1) > > Puppet 2.7.12 > ruby 1.8.7 (patchlevel 352) [x86_64-linux] > > “Sometimes I think the surest sign that intelligent life exists elsewhere > in the universe is that none of it has tried to contact us.” > Bill Waterson (Calvin & Hobbes) > > -- > 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. > >-- Gary Larizza Professional Services Engineer Puppet Labs -- 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.
Dan White
2012-May-29 18:41 UTC
Re: [Puppet Users] I did something stooopid in a custom fact and I do not know what
Fantastic ! Thanks, Gary. I knew it had to be some bone-head boo-boo like that. I trimmed it down further: #Return the broadcast address of eth0 require ''facter'' Facter.add("broadcast") do setcode ("ipcalc -s -b #{Facter.value(''ipaddress'')} #{Facter.value(''netmask'')} | cut -d= -f2") end “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Gary Larizza <gary@puppetlabs.com> wrote:> On Tue, May 29, 2012 at 8:55 AM, Dan White <ygor@comcast.net> wrote: > > > I''m a custom fact n00b :( > > > > ---broadcast.rb: > > #Return the broadcast address of eth0 > > require ''facter'' > > > > Facter.add("broadcast") do > > ipaddr = Facter.value(''ipaddress'') > > nmask = Facter.value(''netmask'') > > setcode do > > Facter::Util::Resolution.exec{"ipcalc -s -b #{ipaddr} #{nmask} | > > cut -d= -f2"} > > > > Try using parenthesis instead of curly braces in > Facter::Util::Resolution.exec () > > You could ALSO do: setcode("ipcalc -s -b #{ipaddr} #{nmask} | cut -d> -f2") > Passing a string to setcode instead of a block pipes the command to > Facter::Util::Resolution.exec() > > > end > > end > > > > ...and when I run puppet apply, I get: > > > > Could not retrieve broadcast: wrong number of arguments (0 for 1) > > > > Puppet 2.7.12 > > ruby 1.8.7 (patchlevel 352) [x86_64-linux] > >> > -- > > Gary Larizza > Professional Services Engineer > Puppet Labs-- 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.
Gary Larizza
2012-May-29 19:12 UTC
Re: [Puppet Users] I did something stooopid in a custom fact and I do not know what
You can go further by removing the require facter line as it should be unnecessary too :) On Tue, May 29, 2012 at 11:41 AM, Dan White <ygor@comcast.net> wrote:> Fantastic ! > Thanks, Gary. I knew it had to be some bone-head boo-boo like that. > > I trimmed it down further: > > #Return the broadcast address of eth0 > require ''facter'' > Facter.add("broadcast") do > setcode ("ipcalc -s -b #{Facter.value(''ipaddress'')} > #{Facter.value(''netmask'')} | cut -d= -f2") > end > > > “Sometimes I think the surest sign that intelligent life exists elsewhere > in the universe is that none of it has tried to contact us.” > Bill Waterson (Calvin & Hobbes) > > ----- Gary Larizza <gary@puppetlabs.com> wrote: > > On Tue, May 29, 2012 at 8:55 AM, Dan White <ygor@comcast.net> wrote: > > > > > I''m a custom fact n00b :( > > > > > > ---broadcast.rb: > > > #Return the broadcast address of eth0 > > > require ''facter'' > > > > > > Facter.add("broadcast") do > > > ipaddr = Facter.value(''ipaddress'') > > > nmask = Facter.value(''netmask'') > > > setcode do > > > Facter::Util::Resolution.exec{"ipcalc -s -b #{ipaddr} #{nmask} | > > > cut -d= -f2"} > > > > > > > Try using parenthesis instead of curly braces in > > Facter::Util::Resolution.exec () > > > > You could ALSO do: setcode("ipcalc -s -b #{ipaddr} #{nmask} | cut -d> > -f2") > > Passing a string to setcode instead of a block pipes the command to > > Facter::Util::Resolution.exec() > > > > > > end > > > end > > > > > > ...and when I run puppet apply, I get: > > > > > > Could not retrieve broadcast: wrong number of arguments (0 for 1) > > > > > > Puppet 2.7.12 > > > ruby 1.8.7 (patchlevel 352) [x86_64-linux] > > > > > > > > -- > > > > Gary Larizza > > Professional Services Engineer > > Puppet Labs > > -- > 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. > >-- Gary Larizza Professional Services Engineer Puppet Labs -- 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.
Dan White
2012-May-29 20:32 UTC
Re: [Puppet Users] I did something stooopid in a custom fact and I do not know what
I will try that and report back. Thanks again for your assistance. ----- Gary Larizza <gary@puppetlabs.com> wrote:> You can go further by removing the require facter line as it should be > unnecessary too :) > > On Tue, May 29, 2012 at 11:41 AM, Dan White <ygor@comcast.net> wrote: > > > Fantastic ! > > Thanks, Gary. I knew it had to be some bone-head boo-boo like that. > > > > I trimmed it down further: > > > > #Return the broadcast address of eth0 > > require ''facter'' > > Facter.add("broadcast") do > > setcode ("ipcalc -s -b #{Facter.value(''ipaddress'')} > > #{Facter.value(''netmask'')} | cut -d= -f2") > > end > >“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) -- 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.