Project

General

Profile

« Previous | Next » 

Revision c33a4433

Added by Mickaël Canévet over 10 years ago

Use concat to create envs sections in puppet.conf

View differences:

manifests/server/env.pp
# Set up a puppet environment
define puppet::server::env ($basedir = $puppet::server_envs_dir) {
define puppet::server::env (
$basedir = $::puppet::server_envs_dir,
$config_version = $::puppet::server::config_version_cmd,
$manifest = undef,
$manifestdir = undef,
$modulepath = [
"${::puppet::server_envs_dir}/${name}/modules",
$::puppet::server_common_modules_path,
],
$templatedir = undef
) {
file { "${basedir}/${name}":
ensure => directory,
}
......
file { "${basedir}/${name}/modules":
ensure => directory,
}
concat_fragment { "puppet.conf+40-${name}":
content => template('puppet/server/puppet.conf.env.erb')
}
}
spec/classes/puppet_server_config_spec.rb
with_content(/^\s+node_terminus\s+= exec$/).
with_content(/^\s+ca\s+= true$/).
with_content(/^\s+ssldir\s+= \/var\/lib\/puppet\/ssl$/).
with({}) # So we can use a trailing dot on each with_content line
should contain_concat_fragment('puppet.conf+40-development').
with_content(/^\[development\]\n\s+modulepath\s+= \/etc\/puppet\/environments\/development\/modules:\/etc\/puppet\/environments\/common:\/usr\/share\/puppet\/modules\n\s+config_version = $/).
with({}) # So we can use a trailing dot on each with_content line
should contain_concat_fragment('puppet.conf+40-production').
with_content(/^\[production\]\n\s+modulepath\s+= \/etc\/puppet\/environments\/production\/modules:\/etc\/puppet\/environments\/common:\/usr\/share\/puppet\/modules\n\s+config_version = $/).
with({}) # So we can use a trailing dot on each with_content line
templates/server/puppet.conf.env.erb
[<%= @name %>]
<% if @manifest -%>
manifest = <%= @manifest %>
<% end -%>
<% if @manifestdir -%>
manifestdir = <%= @manifestdir %>
<% end -%>
<% if @modulepath -%>
modulepath = <%= [@modulepath].flatten.join(":") %>
<% end -%>
<% if @templatedir -%>
templatedir = <%= @templatedir %>
<% end -%>
<% if @config_version -%>
config_version = <%= @config_version_cmd %>
<% end -%>
templates/server/puppet.conf.erb
manifest = <%= scope.lookupvar("puppet::server_envs_dir") %>/$environment/manifests/site.pp
modulepath = <%= scope.lookupvar("puppet::server_envs_dir") %>/$environment/modules
config_version = <%= scope.lookupvar("puppet::server::config_version_cmd") %>
<% else -%>
<% scope.lookupvar("puppet::server_environments").each do |env| -%>
[<%= env %>]
modulepath = <%= scope.lookupvar("puppet::server_envs_dir") %>/<%= env %>/modules:<%= [scope.lookupvar("puppet::server_common_modules_path")].flatten.join(":") %>
config_version = <%= scope.lookupvar("puppet::server::config_version_cmd") %>
<% end -%>
<% end -%>

Also available in: Unified diff