Ask Your Question

How to create an apache vhost in hiera when using puppetlabs/apache

asked 2013-06-07 12:48:45 -0600

jerrac gravatar image

updated 2013-06-09 16:03:26 -0600

ramindk gravatar image

I've installed the module, and I'm trying to set up a vhost on my node. My vm.alpha.lab.json file looks like:

  "classes": [
  "apache::vhost::priority": "10",
  "apache::vhost::vhost_name": "vm.alpha.lab",
  "apache::vhost::port": "80",
  "apache::vhost::docroot": "/var/www"

From the docs say, I should be able to set the apache::vhost's params like that. Unfortunately, I get an error when trying to apply the manifest.

Jun 7 06:20:05 ubuntu-server-12042-x64-vbox4210-nocm puppet-agent[16942]: Could not retrieve catalog from remote server: Error ...

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-06-07 13:58:17 -0600

llowder gravatar image

updated 2013-10-07 10:52:23 -0600

The apache::vhost is not a class, it is a defined type. Databinding currently only works with classes.

If you want to pull this data from hiera, create a hash of hashes and use creste_resources().

    priority: "10"
    vhost_name": "vm.alpha.lab"
    port": "80"
    docroot": "/var/www1"
    priority: "10"
    vhost_name": "vm.beta.lab"
    port": "80"
    docroot": "/var/www2"
    priority": "10"
    vhost_name": "vm.charlie.lab"
    port": "80"
    docroot": "/var/www3"

If you also want to use databindings, you will need to create a wrapper class of some sort that takes the hash of hashes as a parameter.

edit flag offensive delete link more


Ah, that would explain why it doesn't work. Know of any good apache modules that do let you use hiera?

jerrac gravatar imagejerrac ( 2013-06-07 15:02:50 -0600 )edit

The puppetlabs-apache module *does* let you use hiera. What it does not do is import a complete server composition from hiera. I suggest you make a wrapper class that calls ...(more)

supercow gravatar imagesupercow ( 2013-06-09 11:57:37 -0600 )edit

So, I tried using create_resources() in my node definition, but it keeps saying it can't find the vhost template file. The template location is defined in an apache::params ...(more)

jerrac gravatar imagejerrac ( 2013-06-10 14:28:59 -0600 )edit

Make sure you are using the newest version of the module. I don't know off hand about your other question, I'll have to check the code and get ...(more)

llowder gravatar imagellowder ( 2013-06-10 15:03:42 -0600 )edit

Very interesting thread. @jerrac - would it be possible to update your posting with actual working configuration for the puppetlabs/apache + hierra ?

bohdan.m gravatar imagebohdan.m ( 2013-08-12 13:20:50 -0600 )edit

answered 2013-10-04 06:59:43 -0600

jon_proulx gravatar image

This is really a follow on to the very help full suggestion by Llowder, but too long to fit as a comment. First a syntax note, hashes in yaml don't have comas so hiera should be:

        priority: "10"
        vhost_name: "vm.alpha.lab"
        port: "80"
        docroot: "/var/www1"
        priority: "10"
        vhost_name: "vm.beta.lab"
        port: "80"
        docroot: "/var/www2"
        priority: "10"
        vhost_name: "vm.charlie.lab"
        port: "80"
        docroot: "/var/www3"

wrapper is simple, so simple it would be really nice if the module provided one:

class mymodule (
  $vhosts, #hash of vhosts to create, required
  create_resources(apache::vhost, $vhosts)
edit flag offensive delete link more


Requiring vhost is probably a bad idea in case you don't have any. See my question here,

ramindk gravatar imageramindk ( 2013-10-04 12:16:31 -0600 )edit

Sorry about that.. I thought I had removed al the commas when I copied and pasted the data. I'll get that fixed.

llowder gravatar imagellowder ( 2013-10-07 10:51:50 -0600 )edit

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: 2013-06-07 12:48:45 -0600

Seen: 10,397 times

Last updated: Oct 07 '13