dependencies with hiera and create resources

In a nodeless setup it is possible to manage dependencies between resources created by create_resources, but the syntax is quite strict and caused me some troubles. If the syntax is not correct the traditionnal Could not find dependency error message will be displayed.

node default {
  hiera_include ('classes', [])

  $packages = hiera_hash('packages', {})
  create_resources('package', $packages)

  $services = hiera_hash('services', {})
  create_resources('service', $services)
}

The following won’t work:

services:
  mysql:
    ensure: 'running'
    require: Package['mysql-server']

Nor the following:

services:
  mysql:
    ensure: 'running'
    require: "Package['mysql-server']"

But the following two syntaxes will work:

+++
classes:
  - 'puppet::agent'
packages:
  mysql-server:
    ensure: 'installed'
services:
  mysql:
    ensure: 'running'
    require: Package[mysql-server]
+++
classes:
  - 'puppet::agent'
packages:
  mysql-server:
    ensure: 'installed'
services:
  mysql:
    ensure: 'running'
    require: 'Package[mysql-server]'

See a full example running in Vagrant at https://github.com/gwarf/puppet-vagrant-playground


87 Words

2014-04-07 00:00 +0000