Skip to content

Commit

Permalink
add option to manage config_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
pmlee authored and sethlyons committed May 24, 2016
1 parent 8b7f276 commit 41f5e15
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
15 changes: 9 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$custom_fragment = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
$merge_options = $haproxy::merge_options,
) {

if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}
Expand All @@ -21,12 +22,14 @@
warning("${module_name}: The \$merge_options parameter will default to true in the next major release. Please review the documentation regarding the implications.")
}

if $config_dir != undef {
file { $config_dir:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
if $haproxy::params::manage_config_dir {
if $config_dir != undef {
file { $config_dir:
ensure => directory,
owner => '0',
group => '0',
mode => '0755',
}
}
}

Expand Down
25 changes: 13 additions & 12 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,19 @@
# }
#
class haproxy (
$package_ensure = 'present',
$package_name = $haproxy::params::package_name,
$service_ensure = 'running',
$service_manage = true,
$service_options = $haproxy::params::service_options,
$global_options = $haproxy::params::global_options,
$defaults_options = $haproxy::params::defaults_options,
$merge_options = $haproxy::params::merge_options,
$restart_command = undef,
$custom_fragment = undef,
$config_dir = $haproxy::params::config_dir,
$config_file = $haproxy::params::config_file,
$package_ensure = 'present',
$package_name = $haproxy::params::package_name,
$service_ensure = 'running',
$service_manage = true,
$service_options = $haproxy::params::service_options,
$global_options = $haproxy::params::global_options,
$defaults_options = $haproxy::params::defaults_options,
$merge_options = $haproxy::params::merge_options,
$restart_command = undef,
$custom_fragment = undef,
$config_dir = $haproxy::params::config_dir,
$config_file = $haproxy::params::config_file,
$manage_config_dir = $haproxy::params::manage_config_dir,

# Deprecated
$manage_service = undef,
Expand Down
26 changes: 14 additions & 12 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

case $::osfamily {
'Archlinux', 'Debian', 'Redhat', 'Gentoo', 'Suse' : {
$package_name = 'haproxy'
$global_options = {
$package_name = 'haproxy'
$global_options = {
'log' => "${::ipaddress} local0",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
Expand All @@ -23,7 +23,7 @@
'daemon' => '',
'stats' => 'socket /var/lib/haproxy/stats'
}
$defaults_options = {
$defaults_options = {
'log' => 'global',
'stats' => 'enable',
'option' => [ 'redispatch' ],
Expand All @@ -39,15 +39,16 @@
'maxconn' => '8000'
}
# Single instance:
$config_dir = '/etc/haproxy'
$config_file = '/etc/haproxy/haproxy.cfg'
$config_dir = '/etc/haproxy'
$config_file = '/etc/haproxy/haproxy.cfg'
$manage_config_dir = true
# Multi-instance:
$config_dir_tmpl = '/etc/<%= @instance_name %>'
$config_file_tmpl = "${config_dir_tmpl}/<%= @instance_name %>.cfg"
$config_dir_tmpl = '/etc/<%= @instance_name %>'
$config_file_tmpl = "${config_dir_tmpl}/<%= @instance_name %>.cfg"
}
'FreeBSD': {
$package_name = 'haproxy'
$global_options = {
$package_name = 'haproxy'
$global_options = {
'log' => [
'127.0.0.1 local0',
'127.0.0.1 local1 notice',
Expand All @@ -57,7 +58,7 @@
'maxconn' => '4096',
'daemon' => '',
}
$defaults_options = {
$defaults_options = {
'log' => 'global',
'mode' => 'http',
'option' => [
Expand All @@ -72,8 +73,9 @@
'srvtimeout' => '50000',
}
# Single instance:
$config_dir = '/usr/local/etc'
$config_file = '/usr/local/etc/haproxy.conf'
$config_dir = '/usr/local/etc'
$config_file = '/usr/local/etc/haproxy.conf'
$manage_config_dir = false
# Multi-instance:
$config_dir_tmpl = '/usr/local/etc/<%= @instance_name %>'
$config_file_tmpl = "${config_dir_tmpl}/<%= @instance_name %>.conf"
Expand Down

0 comments on commit 41f5e15

Please sign in to comment.