Hi José
Sorry about the delay in responding I was sidetracked with other work. A
massive thank you!!!!!
Your solution works! As a temporary work around I ended up just moving
files in and out of the facter fact.d, this solution is a bit more
convenient.
Thanks,
Peter
On Friday, 9 May 2014 00:54:30 UTC+10, Jose Luis Ledesma wrote:
>
> Hi Peter,
>
> I have been following this thread, but I always readed it with the
> mobile, so sorry for the late answer. The solution is:
>
> # sh -c "$(cat test_values | tr '\n' ' ' ) puppet apply --noop -e
> 'notify{\"\${fqdn}\":}'"
> Notice: Compiled catalog for bob.mgnt.local in environment production in
> 0.02 seconds
> Notice: /Stage[main]/Main/Notify[bob.mgnt.local]/message: current_value
> absent, should be bob.mgnt.local (noop)
> Notice: Class[Main]: Would have triggered 'refresh' from 1 events
> Notice: Stage[main]: Would have triggered 'refresh' from 1 events
> Notice: Finished catalog run in 0.13 seconds
>
> I have changed the notice for a notify (but thats just a test). Keep in
> mind to escape " and $
>
> regards,
>
>
> On Thu, May 8, 2014 at 8:41 AM, Peter <[email protected] <javascript:>>wrote:
>
>> 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]> 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].
>>>>
>>>> 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] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/77d17835-f944-4256-93b6-82eeff86400a%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/77d17835-f944-4256-93b6-82eeff86400a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> José Luis Ledesma
>
--
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/b6019a5b-beb6-4dc9-9753-955ada3036ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.