Skip to content

Instantly share code, notes, and snippets.

@guilhermeblanco
Last active December 22, 2015 14:19
Show Gist options
  • Save guilhermeblanco/6484871 to your computer and use it in GitHub Desktop.
Save guilhermeblanco/6484871 to your computer and use it in GitHub Desktop.
Considering:
ruby --version
1.8.7
And this Hiera content: /var/lib/hiera/node_name.yaml
company::application::config:
'config-common':
root_dir: '%{application_root_dir}/config'
file: 'common.yml'
config:
imports:
- { resource: 'prod.yml' }
Using this in Puppet: /etc/puppet/modules/company/manifests/application.pp
class company::application (
$config = {},
) {
$defaults = {}
create_resources(company::application::configure, $config, $defaults)
}
And this: /etc/puppet/modules/company/manifests/application/configure.pp
define company::application::configure (
$root_dir = '/var/www/application',
$file = 'config.yaml',
$config = {},
) {
if ! defined(Exec["${root_dir}"]) {
exec { "${root_dir}":
path => [ '/bin', '/usr/bin' ],
command => "mkdir -p ${root_dir}",
unless => "test -d ${root_dir}",
}
}
file { "${root_dir}/${file}":
content => inline_template("<%= YAML.dump(@config) %>"),
#content => inline_template("<%= @config.to_yaml( :Separator => '' ) %>"),
owner => 'root',
group => 'root',
mode => '644',
ensure => 'present',
require => File["${root_dir}"],
}
}
I get this:
---
imports:
- resource: prod.yml
But I'm expecting this:
imports:
- resource: prod.yml
How can I achieve it?
I already tried:
<%= @config.to_yaml( :Separator => '' ) %>
And every single option detailed here: http://stackoverflow.com/a/1054841/736364
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment