On Thursday, May 1, 2014 6:07:29 AM UTC-6, Matthew Burgess wrote:
>
> Hi all,
>
> This, to me, is really bizarre.  Here's my code:
>
> Facter.add("hostname_app") do
>     setcode do
>         hostname_app = Facter.value(:hostname)
>         hostname_app[5] = 'a'
>         hostname_app
>     end
> end
>
> Basically, our servers have 2 network cards, and we need to set up DNS for 
> both of its IP addresses.  eth0 & the server's hostname is its 'management' 
> name, and eth1 is the server's 'application'/business network.
>
> The management hostname and application hostname only differ by one 
> letter, which is what the above code is changing.
>
> Now, when this runs, the hostname_app fact is set correctly, but the 
> default hostname fact is also changed similarly!  How on earth is that 
> happening?
>
> I've confirmed that a normal 'facter' run has the correct hostname set, 
> and removing this custom fact also keeps the hostname fact correct under a 
> 'facter -p' run.  However, with this fact in place a 'facter -p' run shows 
> the incorrect hostname fact!
>
> Thanks,
>
> Matt.
>


I too get this on Facter 2.x and ruby 2.1.x. It seems to be returning the 
value as a reference instead of a copy. If you make an explicit copy of the 
variable using something like Facter.value(:whatever).lstrip (the lstrip 
produces a copy of the string) it seems to work fine. It might be worth 
opening a jira ticket for this if you can't find out, as this seems 
really... wrong.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/366a2f50-8654-4a9e-b227-e10ed12beaa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to