Ask Your Question
0

Trouble Parsing a Structured Fact

asked 2015-12-17 18:19:57 -0500

Aaron Copley gravatar image

I am trying to return the UUID for a given partition. This is the closest I can get, but you can see it returns everything in $::partitions, and then appends "[sda1][uuid]" at the end as if it's concatenating a string part.

puppet apply -e 'notify { "$::partitions['sda1']['uuid']": }'
Notice: Compiled catalog for aaron in environment production in 0.05 seconds
Notice: sda1labelbootmount/bootfilesystemext4size1024000uuid3abd6b4e-d17e-4c03-bd64-8df6827c79bbsda2filesystemLVM2_membersize936675328[sda1][uuid]
Notice: /Stage[main]/Main/Notify[sda1labelbootmount/bootfilesystemext4size1024000uuid3abd6b4e-d17e-4c03-bd64-8df6827c79bbsda2filesystemLVM2_membersize936675328[sda1][uuid]]/message: defined 'message' as 'sda1labelbootmount/bootfilesystemext4size1024000uuid3abd6b4e-d17e-4c03-bd64-8df6827c79bbsda2filesystemLVM2_membersize936675328[sda1][uuid]'
Notice: Finished catalog run in 0.03 seconds

So, I try wrapping the hash in brackets without quotes;

puppet apply -e 'notify { ${::partitions['sda1']['uuid']}: }'
Error: Could not parse for environment production: Could not match ${::partitions[sda1][uuid]}: at line 1 on node aaron
Error: Could not parse for environment production: Could not match ${::partitions[sda1][uuid]}: at line 1 on node aaron

And then with quotes;

puppet apply -e 'notify { "${::partitions['sda1']['uuid']}": }'
Error: ::partitions is not a hash or array when accessing it with sda1 at line 1 on node aaron
Error: ::partitions is not a hash or array when accessing it with sda1 at line 1 on node aaron

I have referenced the following question/answer on this site and am still having trouble.

https://ask.puppetlabs.com/question/1...

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2015-12-17 18:39:03 -0500

Aaron Copley gravatar image

Nevermind. I finally found this in the docs for Facter:

Note: Structured facts are supported in Puppet 3.3 and greater, but they aren’t enabled by default. To enable structured facts, set the stringify_facts option to false in the [main] section of puppet.conf on all machines, whether they are agents, masters, or standalone nodes running puppet apply.

Puppet Enterprise 3.7 and later has structured facts enabled by default, as will Puppet 4.0.

https://docs.puppetlabs.com/facter/3....

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-12-17 18:19:57 -0500

Seen: 269 times

Last updated: Dec 17 '15