Hi Brian,

Sorry about the delay in responding.  Unfortunately eval didn't work or at 
least fqdn does not output the value I set it to in test_values.

I am just going to rework my testing to dump a file into 
/etc/facter/facts.d and remove it after use.  Not ideal but it works with 
the least amount of fussing around.  I would have loved to get the 
commandline option working as I would not have to add and remove files when 
I am testing things out.

Thanks,

Peter.

On Tuesday, 6 May 2014 08:29:35 UTC+10, Brian Mathis wrote:
>
> The problem is that your variable names are being returned from the 
> $(cat...) after bash has already evaluated the environment, so it's taking 
> it as a literal string and trying to execute the command.
>
> To get bash to interpret it as a variable, use 'eval':
>    eval $(cat test_values | tr '\n' ' ' ) puppet apply --noop -e 
> 'notice("${fqdn}")'
>
> Also, on modern versions of facter you can place facts in 
> /etc/facter/facts.d and they will override the detected versions.
>
>
> ❧ Brian Mathis
>
>
> On Sat, May 3, 2014 at 7:41 AM, Peter <[email protected] <javascript:>>wrote:
>
>> Hi Puppet Users,
>>
>> Firstly I already know that I can override facter variables by adding 
>> them to the commandline.  Eg:
>>
>> root@dna:~# FACTER_fqdn=foo.bar.info puppet apply --noop -e 
>> 'notice("${fqdn}")'
>> Notice: Scope(Class[main]): foo.bar.info
>> Notice: Compiled catalog for dna.local in environment production in 0.03 
>> seconds
>> Notice: Finished catalog run in 0.04 seconds
>>
>> I would like to use a number of different FACTER overrides, I can add 
>> them all to the command line but I want to test different values at 
>> different times.  I was hoping that I could have a file like:
>> root@dna:~# cat test_values
>> FACTER_hostname=bob
>> FACTER_domain=mgnt.local
>> FACTER_fqdn=bob.mgnt.local
>> FACTER_foo=foo
>>
>> Then like with the hiera command line tool use an option to tell puppet 
>> apply to use this file and override any facts with the same name.  However 
>> there isnt an option.
>>
>> I have found a bash command which will take the values from the file and 
>> concat them together to form one line:
>> root@dna:~# cat test_values | tr '\n' ' '
>> FACTER_hostname=bob FACTER_domain=mgnt.local FACTER_fqdn=bob.mgnt.local 
>> FACTER_foo=foo
>>
>> I was then hoping I could do something like:
>> root@dna:~# $(cat test_values | tr '\n' ' ' ) puppet apply --noop -e 
>> 'notice("${fqdn}")'
>> -bash: FACTER_hostname=bob: command not found
>>
>> However it doesn't work.
>>
>> My question is, does anyone know a puppet way pass a file to puppet apply 
>> which will override facts or if there are any bash experts out there how I 
>> can have the output of the command as plan text.
>>
>> Thanks,
>>
>> Peter
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/puppet-users/fc389ac2-c451-434e-804e-1bbaf9e00117%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/fc389ac2-c451-434e-804e-1bbaf9e00117%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/77d17835-f944-4256-93b6-82eeff86400a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to