Ask Your Question

hiera and type with specific parameters.

asked 2015-02-25 13:12:50 -0600

skc gravatar image

I need to push a specific type via hiera. based on a ::fqdn a node will get different set of parameters in the type.

for example node A will get : php::ini { '/etc/php.ini': allow_call_time_pass_reference => 'Off', display_errors => 'Off', }

and node B will get the same type but with different set of parameters 'php::ini { '/etc/php.ini': error_reporting => 'E_ALL', log_errors => 'On', }

the thing that trips me he here is not passing different VALUES, but different set of parameters.

edit retag flag offensive close merge delete


so I tried doing something like this. in hiera node/%{fqdn} php::ini: /etc/php.ini: allow_call_time_pass_reference : Off display_errors : Off error_reporting : E_ALL in the manifest.pp $phpini = hiera('php::ini', {}) create_resources ('php::ini', $phpini) the catalog compiles just fine but the

skc gravatar imageskc ( 2015-02-25 14:06:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-02-26 10:25:25 -0600

PorkCharSui gravatar image

updated 2015-02-26 10:59:16 -0600

In your /etc/puppet/hiera.yaml have something like:

  - yaml
  - "node/%{fqdn}"

Then create a file datadir/node/(fqdn).yaml with the settings you want to pass to that node and do that for all the different fqdn's/nodes that require different settings something like this:

  allow_call_time_pass_reference: Off
  display_errors: Off

  error_reporting: E_ALL
  log_errors: On

And in your module call hiera with something like this:

class php (
$phpini_settings = hiera_hash('phpini'),
) {
if ! is_hash($phpini_settings) {
    fail('$phpini_settings must be a hash')
create_resources(php::ini', $phpini_settings)

class ini (
  $allow_call_time_pass_reference = undef,
  $display_errors = undef,
  $error_reporting = undef,
  $log_errors = undef,
) {

file { '/etc/php.ini':
  content => " $allow_call_time_pass_reference\

preferably use a template to compose the file, that would be a lot nicer.

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


Asked: 2015-02-25 13:12:50 -0600

Seen: 291 times

Last updated: Feb 26 '15