Ask Your Question
0

hiera - re use of variables

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

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 ::fqdn=ms-vds-1000.xxx.com --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 ...
(more)
edit retag flag offensive close merge delete

Comments

How is this class being included?

ffrank gravatar imageffrank ( 2014-04-03 08:15:43 -0500 )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 -0500 )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 -0500 )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 -0500 )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 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

doc75 gravatar image

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

Indeed my initial answser was wrong (saying this was not possible). It is explained in this article: http://dmsimard.com/2014/02/15/quick-hiera-tips/

Another interesting feature is the anchor mechanism.

edit flag offensive delete link more
0

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

kjgarrett gravatar image

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

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

Stats

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

Seen: 506 times

Last updated: Apr 05 '14