Ask Your Question

PE201502 - Hiera and custom httpd.conf

asked 2015-10-07 22:54:52 -0600

cm01 gravatar image

updated 2015-10-07 22:56:24 -0600

Hi Guys,

I have the following setup in hiera:

 cat common.yaml 
apache::httpd_docroot: /var/www/html

 cat nodes/vm2.local.yaml 
apache::httpd_docroot: /var/www/vm2

This works with

class apache (
    $httpd_docroot      =   hiera('apache::httpd_docroot'),

More explicitly, the above creates the new docroot dir correctly ie /var/www/vm2 for node vm2.local, but what I haven't been able to figure out is how to tell Hiera to customise the DocumentRoot line when generating the httpd.conf OR load a node specific httpd.conf that has the matching DocumentRoot line.

edit retag flag offensive close merge delete


@lupin: thanks, that was just what I was looking for.

Actually, I'm in between jobs at the moment so that's why I'm learning Puppet at home and doing it all the hard way, so to speak.
Obviously in the 'real' world I'd probably borrow a module from forge.

cm01 gravatar imagecm01 ( 2015-10-08 19:00:22 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-10-08 13:19:01 -0600

lupin gravatar image

You need a customisable/templated content for your httpd.conf, in which the value of DocumentRoot is variable and evaluated to whatever the value of $httpd_docroot from Hiera.

e.g. httpd.conf.erb
DocumentRoot <%= @httpd_docroot -%>

on your config file

file { '/etc/httpd/httpd.conf':
  ensure => 'file',
  path   => '/etc/httpd/httpd.conf', 
 content => template('module/httpd.conf.erb')

But this is unnecessary, as there are many apache module on forge.

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-10-07 22:54:52 -0600

Seen: 107 times

Last updated: Oct 08 '15