Re: [Puppet Users] Accessgin facts hash from manifests

2018-04-25 Thread Arnau
Thanks a lot for your answer! it worked.

Best,
Arnau

2018-04-23 11:01 GMT+02:00 Henrik Lindberg :

> On 23/04/18 08:33, Johan De Wit wrote:
>
>> first notify, the index should be quoted 
>>
>> notify { "OS: $facts['os']['family']": }
>>
>>
>> That us unfortunately wrong - it will produce the entire $facts hash as a
> string followed by the *text* "['os']['family']".
>
> The correct way is to write:
>
>   notify { "OS: ${facts['os']['family']}": }
>
> Or, if you like:
>
>   notify { "OS: ${facts.dig('os', 'family')}
>
> (or by using the "pick()" function from stdlib which is similar to "dig()")
>
> Best,
> - henrik
>
> Grts
>>
>>
>>
>>
>> -Original message-
>> *From:* Arnau 
>> *Sent:* Friday 20th April 2018 14:22
>> *To:* puppet-users@googlegroups.com
>> *Subject:* [Puppet Users] Accessgin facts hash from manifests
>>
>>
>> Hi all,
>>
>> I'm having the first experiences with puppet 5 & facter 3
>>
>> In old puppet versions I tend to add debug messages like:
>>
>> notify { "OS : {::osfamily}: }
>>
>> and it usually worked.
>>
>> According to
>> https://puppet.com/docs/puppet/5.3/lang_facts_and_builtin_
>> vars.html#accessing-facts-from-puppet-code
>> > vars.html#accessing-facts-from-puppet-code>
>> I can still access the facts using the old way, but it recommend to
>> use the facts has, so the new code should look like:
>>
>>
>>notify { "OS: $facts[os][family]": }
>>
>> But when I do that I get the full list of facts and [os][family] at
>> the bottom:
>>
>>
>> Notice: OS: {agent_specified_environment => test, aio_agent_version
>> => 5.5.1, architecture => x86_64, augeas => {version => 1.10.1}
>> [ TONS OF FACTS ...]  clientversion => 5.5.1, clientnoop =>
>> false}['os]['family']"
>>
>> If I use the same syntax in a conditiona statement:
>>
>>if $facts['os']['family'] == 'RedHat' {
>>  notify { "I'm a RedHat": }
>>}
>>
>> then it works:
>>
>> Notice: /Stage[main]/Common::Yumrepos/Notify[I'm a RedHat]/message:
>> defined 'message' as 'I\'m a RedHat'
>>
>> So, what's wrong with the above notify?
>>
>>
>> TIA,
>> Arnau
>>
>>
>> -- 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/CAM69jx_sAms0
>> %3Da%2B5MhHBtnydtPKsUDeAAcera8tXSsaANaTchA%40mail.gmail.com
>> > 0%3Da%2B5MhHBtnydtPKsUDeAAcera8tXSsaANaTchA%40mail.gmail.
>> com?utm_medium=email_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 > puppet-users+unsubscr...@googlegroups.com>.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/puppet-users/zarafa.5add7e24.7f1a.78dfd5c52ec466fa%
>> 40zarafa7.open-future.be > sgid/puppet-users/zarafa.5add7e24.7f1a.78dfd5c52ec466fa%
>> 40zarafa7.open-future.be?utm_medium=email_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> Visit my Blog "Puppet on the Edge"
> http://puppet-on-the-edge.blogspot.se/
>
> --
> 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/ms
> gid/puppet-users/pbk789%242rk%241%40blaine.gmane.org.
>
> 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/CAM69jx9wOv-s4TkGYX_vKKUX1k02tO9eLSLbOfbJqyVc3B-0QQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Accessgin facts hash from manifests

2018-04-25 Thread Arnau
Hi,

first of all, thanks for your answer.
Using your code I still see the whole $facts hash

notify { "OS: $facts['os']['family']": }


As Henrik mentioned it must be:

notify { "OS: ${facts['os']['family']}": }

Best,
Arnau

2018-04-23 8:33 GMT+02:00 Johan De Wit :

> first notify, the index should be quoted 
>
> notify { "OS: $facts['os']['family']": }
>
> Grts
>
>
>
>
> -Original message-
> *From:* Arnau 
> *Sent:* Friday 20th April 2018 14:22
> *To:* puppet-users@googlegroups.com
> *Subject:* [Puppet Users] Accessgin facts hash from manifests
>
> Hi all,
>
> I'm having the first experiences with puppet 5 & facter 3
>
> In old puppet versions I tend to add debug messages like:
>
> notify { "OS : {::osfamily}: }
>
> and it usually worked.
>
> According to https://puppet.com/docs/puppet/5.3/lang_facts_and_builtin
> _vars.html#accessing-facts-from-puppet-code I can still access the facts
> using the old way, but it recommend to use the facts has, so the new code
> should look like:
>
>
>   notify { "OS: $facts[os][family]": }
>
> But when I do that I get the full list of facts and [os][family] at the
> bottom:
>
>
> Notice: OS: {agent_specified_environment => test, aio_agent_version =>
> 5.5.1, architecture => x86_64, augeas => {version => 1.10.1}
> [ TONS OF FACTS ...]  clientversion => 5.5.1, clientnoop =>
> false}['os]['family']"
>
> If I use the same syntax in a conditiona statement:
>
>   if $facts['os']['family'] == 'RedHat' {
> notify { "I'm a RedHat": }
>   }
>
> then it works:
>
> Notice: /Stage[main]/Common::Yumrepos/Notify[I'm a RedHat]/message:
> defined 'message' as 'I\'m a RedHat'
>
> So, what's wrong with the above notify?
>
>
> TIA,
> Arnau
>
>
> --
> 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/CAM69jx_sAms0%3Da%2B5MhHBtnydtPKsUDeAAcera8tXSsa
> ANaTchA%40mail.gmail.com
> 
> .
> 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/zarafa.5add7e24.7f1a.78dfd5c52ec466fa%40zarafa7.
> open-future.be
> 
> .
> 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/CAM69jx9JZXckwVUn6ATYi5Arr6cKE8jDgMHyeh-ebBPawjq00g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Accessgin facts hash from manifests

2018-04-23 Thread Henrik Lindberg

On 23/04/18 08:33, Johan De Wit wrote:

first notify, the index should be quoted 

notify { "OS: $facts['os']['family']": }


That us unfortunately wrong - it will produce the entire $facts hash as 
a string followed by the *text* "['os']['family']".


The correct way is to write:

  notify { "OS: ${facts['os']['family']}": }

Or, if you like:

  notify { "OS: ${facts.dig('os', 'family')}

(or by using the "pick()" function from stdlib which is similar to "dig()")

Best,
- henrik


Grts




-Original message-
*From:* Arnau 
*Sent:* Friday 20th April 2018 14:22
*To:* puppet-users@googlegroups.com
*Subject:* [Puppet Users] Accessgin facts hash from manifests

Hi all,

I'm having the first experiences with puppet 5 & facter 3

In old puppet versions I tend to add debug messages like:

notify { "OS : {::osfamily}: }

and it usually worked.

According to

https://puppet.com/docs/puppet/5.3/lang_facts_and_builtin_vars.html#accessing-facts-from-puppet-code


I can still access the facts using the old way, but it recommend to
use the facts has, so the new code should look like:


   notify { "OS: $facts[os][family]": }

But when I do that I get the full list of facts and [os][family] at
the bottom:


Notice: OS: {agent_specified_environment => test, aio_agent_version
=> 5.5.1, architecture => x86_64, augeas => {version => 1.10.1}
[ TONS OF FACTS ...]  clientversion => 5.5.1, clientnoop =>
false}['os]['family']"

If I use the same syntax in a conditiona statement:

   if $facts['os']['family'] == 'RedHat' {
     notify { "I'm a RedHat": }
   }

then it works:

Notice: /Stage[main]/Common::Yumrepos/Notify[I'm a RedHat]/message:
defined 'message' as 'I\'m a RedHat'

So, what's wrong with the above notify?


TIA,
Arnau


-- 
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/CAM69jx_sAms0%3Da%2B5MhHBtnydtPKsUDeAAcera8tXSsaANaTchA%40mail.gmail.com

.
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/zarafa.5add7e24.7f1a.78dfd5c52ec466fa%40zarafa7.open-future.be 
.

For more options, visit https://groups.google.com/d/optout.



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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/pbk789%242rk%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


RE: [Puppet Users] Accessgin facts hash from manifests

2018-04-23 Thread Johan De Wit
first notify, the index should be quoted 

notify { "OS: $facts['os']['family']": }


Grts







-Original message-
From: Arnau 
Sent: Friday 20th April 2018 14:22
To: puppet-users@googlegroups.com
Subject: [Puppet Users] Accessgin facts hash from manifests

Hi all,

I'm having the first experiences with puppet 5 & facter 3 

In old puppet versions I tend to add debug messages like:

notify { "OS : {::osfamily}: }

and it usually worked.

According to 
https://puppet.com/docs/puppet/5.3/lang_facts_and_builtin_vars.html#accessing-facts-from-puppet-code
 I can still access the facts using the old way, but it recommend to use the 
facts has, so the new code should look like:


  notify { "OS: $facts[os][family]": }

But when I do that I get the full list of facts and [os][family] at the bottom:


Notice: OS: {agent_specified_environment => test, aio_agent_version => 5.5.1, 
architecture => x86_64, augeas => {version => 1.10.1}
[ TONS OF FACTS ...]  clientversion => 5.5.1, clientnoop => 
false}['os]['family']"

If I use the same syntax in a conditiona statement:

  if $facts['os']['family'] == 'RedHat' {
    notify { "I'm a RedHat": }
  }

then it works:

Notice: /Stage[main]/Common::Yumrepos/Notify[I'm a RedHat]/message: defined 
'message' as 'I\'m a RedHat'

So, what's wrong with the above notify? 


TIA,
Arnau

 

-- 
 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/CAM69jx_sAms0%3Da%2B5MhHBtnydtPKsUDeAAcera8tXSsaANaTchA%40mail.gmail.com.
 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/zarafa.5add7e24.7f1a.78dfd5c52ec466fa%40zarafa7.open-future.be.
For more options, visit https://groups.google.com/d/optout.