Thanks, i think i got something here:

Facter.add("ip_prodlan") do
   confine :kernel => "Linux"
   setcode do
      Facter::Util::Resolution.exec("/sbin/ifconfig | /bin/grep 
'20.20.\\|30.31.\\|200.30.80.\\|120.' | /bin/awk '{ print $2 }' | /bin/cut 
-d':' -f2 | /usr/bin/head -n1")
   end
end

I'm currently using the custom fact to print the production LAN ip address 
in /etc/motd .
It usually returns the correct value. But in some cases the "puppet agent 
-t" command changes the file in a *different* way than "service puppet 
restart" does. Any idea?

Another question:

I want my custom fact to do something like this:
if the "Resolution.exec" returns 0 (nothing) then ip_prodlan should use the 
value of the fact "$ipaddress".
Is it possible to do something like this?


On Thursday, November 21, 2013 10:36:52 PM UTC+1, Jo wrote:
>
> Yep, write it out as such :)  Either if/then in the manifest, or write a 
> custom function that iterates through all ipaddress facts.
>
> On Nov 21, 2013, at 4:32 AM, cko <der...@gmail.com <javascript:>> wrote:
>
> I'm currently trying to solve the following problem:
>
> I wrote a module that matches the "$ipaddress" fact for certain IP subnets 
> (like 20.20.2... or 30.30.2..). Depending on the subnet, the variable 
> $proxy-server changes.
>
> The problem is, that some of our physical machines have a random number of 
> interfaces connected to many different subnets. In some cases the 
> $ipadddress fact returns the correct subnet, lets call it "production 
> server lan" and some don't.
>
> Is there any way to make puppet check every available NIC for a specific 
> subnet/ regex? Something like this:
>
> if $ipaddress_eth*** =~ /^20\.20\.\..*$/ {
>    $proxy-server = foo 
> }
> . 
>
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/9e5f1c49-cf71-4eab-a11b-18a9d31b5b0a%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> -- 
> Jo Rhett
> Net Consonance : net philanthropy to improve open source and 
> internet projects.
>
> Author of Instant Puppet 3 Starter: 
> http://www.netconsonance.com/instant-puppet-3-starter-book/
>
>
>  
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f9847332-1266-4ca7-88e0-cff871964d60%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to