rspec and structured facts

248 views
Skip to first unread message

Johan De Wit

unread,
Mar 9, 2015, 10:54:35 AM3/9/15
to puppe...@googlegroups.com
Again , I'm loosing the fight

When i split up my rspec, it works, but the demo test always fails,
There is something I overlook.

Maybe someone else sees my mistake ??

https://github.com/witjoh/rspec

Grts

Johan

--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
Puppet Certified Intstructor
blog : http://johan.koewacht.net/
_________________________________________________________

Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________


Next Events:
Puppet Fundamentals | http://www.open-future.be/puppet-fundamentals-training-16th-till-18th-march
Puppet Architect | http://www.open-future.be/puppet-architect-training-19th-till-20th-march
Puppet Practitioner | http://www.open-future.be/puppet-practitioner-training-14th-till-16th-april
Linux Training | http://www.open-future.be/linux-training-20th-till-24th-april
Bacula Administrator 1 | http://www.open-future.be/bacula-administrator-i-training-28th-till-30th-april
Zabbix Certified Specialist | http://www.open-future.be/zabbix-certified-specialist-training-4th-till-6th-may
Zabbix Certified Professional | http://www.open-future.be/zabbix-certified-professional-training-7th-till-8th-may
Subscribe to our newsletter | http://eepurl.com/BUG8H

Raphaël Pinson

unread,
Mar 9, 2015, 11:08:05 AM3/9/15
to puppe...@googlegroups.com
Hi Johan,


It works for me. By that, I mean I get two errors:

* One error for the first test, when it meets $::os['family'], since $::os is not defined in the first test case
* One error for the second test, since $::os['release'] is not defined in this case


Cheers,

Raphaël

Felix Frank

unread,
Mar 9, 2015, 11:13:33 AM3/9/15
to puppe...@googlegroups.com
Hi,

me I'm now utterly confused by how this (not) works in the wild.

$ bundle exec puppet apply -e 'notice $os'
Notice: Scope(Class[main]): {"name"=>"Debian", "family"=>"Debian",
"release"=>{"major"=>"jessie/sid", "full"=>"jessie/sid"},
"lsb"=>{"distcodename"=>"sid", "distid"=>"Debian",
"distdescription"=>"Debian GNU/Linux unstable (sid)",
"distrelease"=>"unstable", "majdistrelease"=>"unstable"}}

OK, but

$ bundle exec puppet apply -e 'notice $os[name]'
Error: os is not a hash or array when accessing it with name at line 1
on node hypnos.mpex.net

$ bundle exec puppet apply --parser=future -e 'notice $os["name"]'
Error: Evaluation Error: The value 'name' cannot be converted to
Numeric. on node hypnos.mpex.net

This is Puppet 3.7.3. Please tell me I'm Doing It Wrong.

Thanks,
Felix

Raphaël Pinson

unread,
Mar 9, 2015, 11:21:11 AM3/9/15
to puppe...@googlegroups.com
Hi Felix,


By default, Puppet 3 stringifies all facts. And apparently, "--stringify_facts false" does not work with puppet apply…


Raphaël

Felix Frank

unread,
Mar 9, 2015, 11:24:29 AM3/9/15
to puppe...@googlegroups.com
On 03/09/2015 04:21 PM, Raphaël Pinson wrote:
> Hi Felix,
>
>
> By default, Puppet 3 stringifies all facts. And apparently,
> "--stringify_facts false" does not work with puppet apply…
>
>
> Raphaël

I see. Well that's a relief ;-)

In a disturbing, not at all relieving way...

Thanks again,
Felix

Johan De Wit

unread,
Mar 9, 2015, 5:11:20 PM3/9/15
to puppe...@googlegroups.com
now I'm really embarrassed ...

hiding with dark red cheeks .....


In the demo_spec file, i don't have to test three context, because I only have one, using the osfamily fact, and the structures os fact (twice).

Now I'm green for all tests !!

Thanks for opening my (so closed) eyes.

I own you a really big beer .....
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/6fa68a2d-0f1e-48c3-8850-7efa6f6c4bce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer              (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
Puppet Certified Intstructor 
blog : http://johan.koewacht.net/
_________________________________________________________
 
Open-Future                 Phone     +32 (0)2/255 70 70
Zavelstraat 72              Fax       +32 (0)2/255 70 71
3071 KORTENBERG             Mobile    +32 (0)474/42 40 73
BELGIUM                     http://www.open-future.be
_________________________________________________________
 

Upcoming Events:

Johan De Wit

unread,
Mar 9, 2015, 5:36:00 PM3/9/15
to puppe...@googlegroups.com
Lets add some extra confusion here :

[witjoh@fc20 spec]$ puppet apply -e 'notify { $::os: }'
Notice: Compiled catalog for fc20.koewacht.net in environment production in 0.03 seconds
Notice: {"name"=>"Fedora", "family"=>"RedHat", "release"=>{"major"=>"20", "full"=>"20"}}
Notice: /Stage[main]/Main/Notify[{"name"=>"Fedora", "family"=>"RedHat", "release"=>{"major"=>"20", "full"=>"20"}}]/message: defined 'message' as '{"name"=>"Fedora", "family"=>"RedHat", "release"=>{"major"=>"20", "full"=>"20"}}'
Notice: Finished catalog run in 0.11 seconds
[witjoh@fc20 spec]$ puppet apply -e 'notify { $::os[name]: }'
Notice: Compiled catalog for fc20.koewacht.net in environment production in 0.02 seconds
Notice: Fedora
Notice: /Stage[main]/Main/Notify[Fedora]/message: defined 'message' as 'Fedora'
Notice: Finished catalog run in 0.12 seconds
[witjoh@fc20 spec]$ puppet apply -e 'notify { $::os["name"]: }'
Notice: Compiled catalog for fc20.koewacht.net in environment production in 0.03 seconds
Notice: Fedora
Notice: /Stage[main]/Main/Notify[Fedora]/message: defined 'message' as 'Fedora'
Notice: Finished catalog run in 0.11 seconds
[witjoh@fc20 spec]$ puppet --version
3.7.4 (Puppet Enterprise 3.7.2)

and when i do the same in my rspec module,  it does no work in the same way :

[witjoh@fc20 rspec]$ bundle exec puppet apply --stringify_facts false -e 'notify { $::os["name"]: }'
Error: ::os is not a hash or array when accessing it with name at line 1 on node fc20.koewacht.net

[witjoh@fc20 rspec]$ bundle exec puppet apply --stringify_facts false -e 'notify { $::os[name]: }'
Error: ::os is not a hash or array when accessing it with name at line 1 on node fc20.koewacht.net

[witjoh@fc20 rspec]$ bundle exec puppet apply --stringify_facts false -e 'notify { $::os: }'
Notice: Compiled catalog for fc20.koewacht.net in environment production in 0.03 seconds
Notice: {"name"=>"Fedora", "family"=>"RedHat", "release"=>{"major"=>"20", "full"=>"20"}}
Notice: /Stage[main]/Main/Notify[{"name"=>"Fedora", "family"=>"RedHat", "release"=>{"major"=>"20", "full"=>"20"}}]/message: defined 'message' as '{"name"=>"Fedora", "family"=>"RedHat", "release"=>{"major"=>"20", "full"=>"20"}}'
Notice: Finished catalog run in 0.10 seconds

[witjoh@fc20 rspec]$ bundle exec puppet apply --stringify_facts false --configprint all | grep stringify
stringify_facts = true

[witjoh@fc20 rspec]$ bundle exec puppet apply --stringify_facts false --configprint all | grep stringify
stringify_facts = true

Defaults are different between my PE and gem puppet :
[witjoh@fc20 rspec]$ puppet apply --configprint stringify_facts
false
[witjoh@fc20 rspec]$ bundle exec puppet apply --configprint stringify_facts
true

Seems PE en gem (os) installation have different defaults  since i did not set this config ...
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
-- 
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer              (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
Puppet Certified Intstructor 
blog : http://johan.koewacht.net/
_________________________________________________________
 
Open-Future                 Phone     +32 (0)2/255 70 70
Zavelstraat 72              Fax       +32 (0)2/255 70 71
3071 KORTENBERG             Mobile    +32 (0)474/42 40 73
BELGIUM                     http://www.open-future.be
_________________________________________________________
 

Upcoming Events:

Kylo Ginsberg

unread,
Mar 10, 2015, 2:19:59 AM3/10/15
to puppe...@googlegroups.com
On Mon, Mar 9, 2015 at 8:21 AM, Raphaël Pinson <raphael...@camptocamp.com> wrote:
Hi Felix,

By default, Puppet 3 stringifies all facts. And apparently, "--stringify_facts false" does not work with puppet apply…

For any boolean setting, "--some_boolean false" doesn't work, and you instead need to use "--no-some_boolean".

So in this case, this seems to work:

puppet apply --parser=future --no-stringify_facts -e 'notify{ "${os['name']}": }'

Kylo
 

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/902db327-b5fb-4289-9123-20066c0646be%40googlegroups.com.

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



--
Kylo Ginsberg | ky...@puppetlabs.com | irc: kylo | twitter: @kylog

PuppetConf 2015 is coming to Portland, Oregon! Join us October 5-9.
Register now to take advantage of the Early Adopter discount save $349!

Raphaël Pinson

unread,
Mar 10, 2015, 2:48:59 AM3/10/15
to puppe...@googlegroups.com
Thanks for that clarification Henrik.

Also, having seen such behaviour before, it appears that PE is patched to default to *not* stringifying facts, unlike the corresponding open source version, which is why your test with PE behaved differently than with bundle.

Raphaël Pinson

unread,
Mar 10, 2015, 2:51:16 AM3/10/15
to puppe...@googlegroups.com
Sorry Kylo, I thought the last post was from Henrik and my phone won't let me see the full thread while replying...

Felix Frank

unread,
Mar 10, 2015, 5:11:42 AM3/10/15
to puppe...@googlegroups.com
On 03/10/2015 07:19 AM, Kylo Ginsberg wrote:
> On Mon, Mar 9, 2015 at 8:21 AM, Raphaël Pinson
> <raphael...@camptocamp.com <mailto:raphael...@camptocamp.com>>
> wrote:
>
> Hi Felix,
>
> By default, Puppet 3 stringifies all facts. And apparently,
> "--stringify_facts false" does not work with puppet apply…
>
>
> For any boolean setting, "--some_boolean false" doesn't work, and you
> instead need to use "--no-some_boolean".
>
> So in this case, this seems to work:
>
> puppet apply --parser=future --no-stringify_facts -e 'notify{
> "${os['name']}": }'
>
> Kylo

Excellent. Works for me now. Not yet sure what that implies for
rspec-puppet.

Thanks Kylo!
Reply all
Reply to author
Forward
0 new messages