Skip to content

Commit

Permalink
Add configs using files in conf.d
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Baranov <[email protected]>
  • Loading branch information
spacedog committed Mar 18, 2016
1 parent a74415c commit 3281003
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
47 changes: 47 additions & 0 deletions manifests/siteconfig.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
define rt::siteconfig (
$value = undef,
$ensure = 'present',
$order = '99',
) {

include ::rt::params
# Valitaion
validate_re($ensure, [
'^absent$',
'^present$'
])
validate_string(
$order
)

# Variables
$config_d = hiera('rt::config_d', $rt::params::config_d)
validate_absolute_path($config_d)

$web_user = hiera('rt::web_user', $rt::params::web_user)
$web_group = hiera('rt::web_group', $rt::params::web_group)
validate_string(
$web_user,
$web_group
)

$target_path = "${config_d}/${order}-${title}.pm"

# Files and Directories
file { $target_path:
ensure => $ensure,
mode => '0640',
owner => $web_user,
group => $web_group,
content => template("${module_name}/RT_SiteConfig-fragment.pm.erb"),
notify => Exec["${target_path} syntax check"]
}

# Execs
exec { "${target_path} syntax check":
path => ['/bin', '/usr/bin'],
command => "perl -c ${target_path}",
refreshonly => true,
}

}
18 changes: 18 additions & 0 deletions templates/RT_SiteConfig-fragment.pm.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File is generated by puppet
use utf8;
<%- if @value.is_a? Hash-%>
Set(%<%= @title %>,
<% @value.sort.each do |k,v| -%>
<%= k %>' => '<%= v %>',
<%- end -%>
);
<%- elsif @value.is_a? Array -%>
Set(@<%= @title %>,
<% @value.sort.each do |v| -%>
'<%= v %>',
<% end -%>
);
<%- else -%>
Set($<%= @title %>, '<%= @value %>');
<%- end -%>
1;

0 comments on commit 3281003

Please sign in to comment.