OK, I think this is probably something that is entirely my fault, but I
cannot access a facter fact that I need. It evaluates only on certain
clients, and is dependent upon the creation and value of another fact.
Client and server are puppet 2.6.6 and facter 1.5.9.
Custom fact defined in common module:
/etc/puppetdev/modules/common/lib/facter/openldap.rb
Facter.add("is_ldap_server") do
setcode do
if FileTest.exists?("/usr/sbin/slapd")
Facter.add("ldap_rid") do
setcode do
case Facter::network_eth0
when "192.168.96.0"
Facter::ipaddress[/[0-9]+$/].chomp
when "192.168.97.0"
( 500 + Facter::ipaddress_eth0[/[0-9]+$/].chomp.to_i )
end
end
end
%x{echo yes}.chomp
else
%x{echo no}.chomp
end
end
end
This fact does evaluate on the client in question:
ldap_rid => 529
However, whatever way I use to try to find it in my template fails...can
someone please help?
Attempted syntaxes:
<%= @ldap_rid %>
<% @ldap_rid %>
<%= ldap_rid %>
<% ldap_rid %>
<%= scope.lookupvar("ldap_rid") %>
<%= scope.lookupvar("::ldap_rid") %>
...probably others as well. I''m probably just scoping it wrong, but
every
time it comes up as blank or ''undef''.
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/INd3uN7go6sJ.
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.
Well, whatever problem I''m seeing is due to the nested Facter.add statements...when I pulled the ldap_rid one out and ran it separately, it worked. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/rVoETeJ5MqwJ. 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 have it working, but I''m curious if this might be a bug with nested
Facter.add statements?
I simply un-nested them and used a ''confine'' statement to make
things work.
New facts posted below:
Facter.add("is_ldap_server") do
setcode do
if FileTest.exists?("/usr/sbin/slapd")
%x{echo yes}.chomp
else
%x{echo no}.chomp
end
end
end
Facter.add("ldap_rid") do
confine :is_ldap_server => :yes
setcode do
case Facter::network_eth0
when "192.168.96.0"
Facter::ipaddress[/[0-9]+$/].chomp
when "192.168.97.0"
( 500 + Facter::ipaddress_eth0[/[0-9]+$/].chomp.to_i )
end
end
end
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/ob5dE8e2afMJ.
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.
IMHO I don''t think I want nested facts to work :-). The evaluation order alone is trouble some ... ie. the inner fact wouldn''t get added until the enclosed fact is evaluated ... doesn''t sound like something you would want in ordinary circumstances :-). Remember sometimes fact information is gather on a per-fact basis and doing nesting would break this for your inner fact. I think using the confine is fine :-). ken. On Fri, Jul 15, 2011 at 7:02 PM, Greg Etling <getling@stern.nyu.edu> wrote:> I have it working, but I''m curious if this might be a bug with nested > Facter.add statements? > I simply un-nested them and used a ''confine'' statement to make things work. > New facts posted below: > Facter.add("is_ldap_server") do > setcode do > if FileTest.exists?("/usr/sbin/slapd") > %x{echo yes}.chomp > else > %x{echo no}.chomp > end > end > end > Facter.add("ldap_rid") do > confine :is_ldap_server => :yes > setcode do > case Facter::network_eth0 > when "192.168.96.0" > Facter::ipaddress[/[0-9]+$/].chomp > when "192.168.97.0" > ( 500 + Facter::ipaddress_eth0[/[0-9]+$/].chomp.to_i ) > end > end > end > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/puppet-users/-/ob5dE8e2afMJ. > 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. >-- "Join us for PuppetConf, September 22nd and 23rd in Portland, OR: http://bit.ly/puppetconfsig" -- 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.