Ask Your Question

hiera - re use of variables

asked 2014-03-25 09:18:11 -0600

kjgarrett gravatar image

I have a hiera yaml file which has the following contents

  "::user" : "ul215669",
  "::home_dir" : "/home/%{hiera('::user')}/",
  "vds_user::username" : %{hiera('::user')},


from a UNIX command line I execute this command

hiera vds_user::username --debug

and see the following result

DEBUG: Tue Mar 25 14:10:30 +0000 2014: Hiera YAML backend starting
DEBUG: Tue Mar 25 14:10:30 +0000 2014: Looking up vds_user::username in YAML backend
DEBUG: Tue Mar 25 14:10:30 +0000 2014: Looking for data source defaults
DEBUG: Tue Mar 25 14:10:30 +0000 2014: Looking for data source node ...
edit retag flag offensive close merge delete


How is this class being included?

ffrank gravatar imageffrank ( 2014-04-03 08:15:43 -0600 )edit

The class , vds_user, is included from the init.pp for the vds module. The init.pp receives two variables , neither of which were mentioned in the sample above. the vds_user ...(more)

kjgarrett gravatar imagekjgarrett ( 2014-04-08 03:57:23 -0600 )edit

Okay. Which Puppet version is this? Are you using include vds_user or class { "vds_user": } ?

ffrank gravatar imageffrank ( 2014-04-08 07:17:12 -0600 )edit

Its puppet 3.3.1 and the init.pp contains class vds{$user, $version) { class{'vds_user':} -> class {'vds_software'} }

kjgarrett gravatar imagekjgarrett ( 2014-04-08 07:36:26 -0600 )edit

Can you enable debug output in your puppetmaster and share the output that pertains to Hiera, as you did with the hiera commandline above?

ffrank gravatar imageffrank ( 2014-04-08 08:48:24 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-03-25 12:55:27 -0600

doc75 gravatar image

updated 2014-04-05 14:14:25 -0600

Indeed my initial answser was wrong (saying this was not possible). It is explained in this article:

Another interesting feature is the anchor mechanism.

edit flag offensive delete link more

answered 2014-03-26 03:46:48 -0600

kjgarrett gravatar image

updated 2014-03-26 03:47:20 -0600

I made some progress with this. It seems that unless a parameter is passed to a class in a module that it cant be access/re-used in another class. Also it doesnt seem possible to reuse a parameter in the same class

so this sets vdsuser:homedir correctly

vds::username : "BobbyWomack",
vds_user::home_dir : "/home/%{vds::username}",

but this doesnt set vdsuser::datastore

vds_user::home_dir : "/home/%{vds::username}",,
vds_user::data_store : "%{vds_user::home_dir}/data",
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


Asked: 2014-03-25 09:18:11 -0600

Seen: 637 times

Last updated: Apr 05 '14