Hi, I''ve got a facter shipped with a custom module. This factor returns the version of a determined package. It returns nil if the package is not installed yet. When running for the first time, assuming the package is not installed, the facter will be still nil. When referring to that facter in the manifest - for example in a file resource - it fails, because it has been compiled with a nil value. When the package is already installed, it works great. Just out of curiosity, is there any workaround other than if/else statements? Thanks, -frederiko -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Ellison Marks
2013-Sep-20 17:25 UTC
[Puppet Users] Re: Facter value at Catalog compilation
Post the code for the custom fact? On Thursday, September 19, 2013 2:23:15 PM UTC-7, Frederiko Costa wrote:> > Hi, > > I''ve got a facter shipped with a custom module. This factor returns the > version of a determined package. It returns nil if the package is not > installed yet. > > When running for the first time, assuming the package is not installed, > the facter will be still nil. When referring to that facter in the manifest > - for example in a file resource - it fails, because it has been compiled > with a nil value. When the package is already installed, it works great. > > Just out of curiosity, is there any workaround other than if/else > statements? > > Thanks, > -frederiko > >-- 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. For more options, visit https://groups.google.com/groups/opt_out.
Frederiko Costa
2013-Sep-20 18:38 UTC
Re: [Puppet Users] Re: Facter value at Catalog compilation
Sure ... Here it is: # # terracota_version.rb # # Reports terracota version if terracotta is installed Facter.add(:terracotta_version) do cmd = %x{/bin/rpm -qa terracotta --queryformat %{VERSION}} setcode do if ! cmd.nil? cmd else nil end end end -frederiko On Fri, Sep 20, 2013 at 10:25 AM, Ellison Marks <gtyaoi@gmail.com> wrote:> Post the code for the custom fact? > > > On Thursday, September 19, 2013 2:23:15 PM UTC-7, Frederiko Costa wrote: >> >> Hi, >> >> I''ve got a facter shipped with a custom module. This factor returns the >> version of a determined package. It returns nil if the package is not >> installed yet. >> >> When running for the first time, assuming the package is not installed, >> the facter will be still nil. When referring to that facter in the manifest >> - for example in a file resource - it fails, because it has been compiled >> with a nil value. When the package is already installed, it works great. >> >> Just out of curiosity, is there any workaround other than if/else >> statements? >> >> Thanks, >> -frederiko >> >> -- > 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. > 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. For more options, visit https://groups.google.com/groups/opt_out.
On Thursday, September 19, 2013 4:23:15 PM UTC-5, Frederiko Costa wrote:> > Hi, > > I''ve got a facter shipped with a custom module. This factor returns the > version of a determined package. It returns nil if the package is not > installed yet. > > When running for the first time, assuming the package is not installed, > the facter will be still nil. When referring to that facter in the manifest > - for example in a file resource - it fails, because it has been compiled > with a nil value. When the package is already installed, it works great. > > Just out of curiosity, is there any workaround other than if/else > statements? > >Like what? Puppet has more conditional statements than just if/else, but I''m having trouble seeing how you imagine being able to handle a special case such as you describe without using any of them. Were you also seeking advice about your bootstrapping problem? If so, then it would be helpful to have some information about how your custom fact is used, and more generally what your module is trying to accomplish. John -- 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. For more options, visit https://groups.google.com/groups/opt_out.