Hey Hristo,

This did not work for me but I wanted to thank you for the info.  It turns 
out the fact wasn't being sync'd correctly to the client and therefore not 
all my changes were being reflected locally.

Thank you again for the info. 

Cheers,

Mike.

On Wednesday, January 13, 2016 at 3:26:18 AM UTC-8, Hristo Mohamed wrote:
>
> Try :
> setcode { network }
>
> From puppett docs:
>
>
>    1. A call to Facter.add('fact_name'), which determines the name of the 
>    fact
>    2. A setcode statement for simple resolutions, which is evaluated to 
>    determine the fact’s value.
>
>
> On Wed, Jan 13, 2016 at 12:42 AM, Mike Reed <mjohn...@gmail.com 
> <javascript:>> wrote:
>
>> Hello all,
>>
>> I'm having some trouble with a custom fact and I was hoping somebody 
>> could tell me what I'm doing wrong.  
>>
>> Here is an example of the code:
>>
>> require 'facter'
>> Facter.add('network') do
>>   setcode do
>>     hostname = Facter.value(:hostname)
>>     ipaddress = Facter.value(:ipaddress)
>>     case 
>>       when 
>> ipaddres.match(/^(\d[10]\.)(\d[10]\.)([1][2][7]\.)([1-9][1-9][1-9])?/)
>>         network = 'net1'  
>>       when hostname.match(/^nettwo/)
>>         network = 'net2'
>>       when hostname.match(/^netthree/)
>>         network = 'net3'
>>       when hostname.match(/^netfour/)
>>         network = 'net4'
>>       else
>>         network = 'nonet'
>>       end
>>     network
>>     end
>> end
>>
>> I've gotten myself into a pickle in that most hosts have a hostname 
>> prefix to designate what network they are on.  In this case, I don't have a 
>> prefix but the physical ip is different and my thoughts were to regex match 
>> the ip address and bingo...but no luck.
>>
>> Puppet runs and pluginsync does pull down the fact but I never get the 
>> value of network back.   No errors are displayed or logged when running 
>> 'facter -p' but again, I never get the value of network back.  I've done 
>> quite a bit of reading and can't figure out why this one doesn't work.  
>>
>> Does anybody perhaps have any suggestions as to how I might accomplish 
>> this?
>>
>> Thank you in advance for your assistance.
>>
>> Cheers,
>>
>> Mike
>>
>> -- 
>> 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/cbf9ea68-fffd-4e14-a467-486d8832bc0e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/puppet-users/cbf9ea68-fffd-4e14-a467-486d8832bc0e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/4d44092b-6b1f-4999-8a52-c7b0b41a5150%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to