Pass variable to class from hiera puppetlabs-apache

1,056 views
Skip to first unread message

Yuriy Gerasimov

unread,
Dec 13, 2013, 6:03:17 AM12/13/13
to puppet...@googlegroups.com
Hi,

I am cleaning my manifest by moving things to hiera yaml config file.

For the https://github.com/puppetlabs/puppetlabs-apache I need to pass mpm_module variable as false like:

class { 'apache':
  mpm_module => false
}

But I can't figure out how to do this in hiera yaml file. I include classes using hiera_include('classes').

I tried 

classes:
     - apache
     - apache::mpm_module: false
     - apache::mod::prefork
     - apache::mod::php
     - apache::mod::rewrite
     - apache::mod::ssl

But I get error

Error: undefined method `downcase' for {"apache::mpm_module"=>false}:Hash at /tmp/vagrant-puppet/manifests/site.pp:13 on node precise64.asus

Please advise how properly pass variables to classes in yaml files?

Thank you a lot

Yuriy

Paul Archer

unread,
Dec 13, 2013, 5:13:22 PM12/13/13
to puppet...@googlegroups.com
The classes indicator/variable/key (whatever it's officially called) is only for classes. 
Then in the appropriate yaml file, specify:
apache::mpm_module: false
or whatever. It's that easy.

So your file should look like:

classes:
     - apache

apache::mpm_module: false
apache::mod::prefork: true
apache::mod::php: this
apache::mod::rewrite: that
apache::mod::ssl: "the other"

jcbollinger

unread,
Dec 16, 2013, 9:23:07 AM12/16/13
to puppet...@googlegroups.com


On Friday, December 13, 2013 4:13:22 PM UTC-6, Paul Archer wrote:
The classes indicator/variable/key (whatever it's officially called) is only for classes. 
Then in the appropriate yaml file, specify:
apache::mpm_module: false
or whatever. It's that easy.

So your file should look like:

classes:
     - apache

apache::mpm_module: false
apache::mod::prefork: true
apache::mod::php: this
apache::mod::rewrite: that
apache::mod::ssl: "the other"



Exactly so.  The latter part is an exercise of Puppet 3's automatic data binding feature, and it is applicable to any of the available mechanisms by which you can declare classes, either directly or indirectly.  Class parameter values defined that way in your hiera hierarchy will be effective whether you 'include', 'require', or 'contain' (coming soon) a class, or if you declare it via hiera_include() or another function.  They will be effective also if you use parameterized-style class declarations, except that parameter values declared explicitly in such a declaration override hiera data.


John

Reply all
Reply to author
Forward
0 new messages