Skip to content

Commit

Permalink
Merge pull request #506 from tuxmea/manage_conf_dir
Browse files Browse the repository at this point in the history
[MODULES-11274] Allow usage of parameter manage_config_dir
  • Loading branch information
david22swan authored May 11, 2022
2 parents 3382ddf + 2e866ba commit 24049ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ node 'haproxy-server' {
include ::haproxy
haproxy::listen { 'puppet00':
collect_exported => false,
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8140',
}
haproxy::balancermember { 'server00':
Expand Down Expand Up @@ -70,7 +70,7 @@ The main [`haproxy` class](#class-haproxy) has many options for configuring your
~~~puppet
class { 'haproxy':
global_options => {
'log' => "${::ipaddress} local0",
'log' => "${facts['networking']['ip']} local0",
'chroot' => '/var/lib/haproxy',
'pidfile' => '/var/run/haproxy.pid',
'maxconn' => '4000',
Expand Down Expand Up @@ -151,7 +151,7 @@ To export the resource for a balancermember and collect it on a single HAProxy l

~~~puppet
haproxy::listen { 'puppet00':
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8140',
mode => 'tcp',
options => {
Expand Down Expand Up @@ -195,8 +195,8 @@ First export the resource for a balancermember:
@@haproxy::balancermember { 'haproxy':
listening_service => 'puppet00',
ports => '8140',
server_names => $::hostname,
ipaddresses => $::ipaddress,
server_names => $facts['networking']['hostname'],
ipaddresses => $facts['networking']['ip'],
options => 'check',
}
~~~
Expand Down Expand Up @@ -229,16 +229,16 @@ Install and configure an HAProxy service listening on port 8140 and balanced aga
node 'haproxy-server' {
include ::haproxy
haproxy::listen { 'puppet00':
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8140',
}
}
node /^server\d+/ {
@@haproxy::balancermember { $::fqdn:
@@haproxy::balancermember { $facts['networking']['fqdn']:
listening_service => 'puppet00',
server_names => $::hostname,
ipaddresses => $::ipaddress,
server_names => $facts['networking']['hostname'],
ipaddresses => $facts['networking']['ip'],
ports => '8140',
options => 'check',
}
Expand All @@ -253,7 +253,7 @@ This example routes traffic from port 8140 to all balancermembers added to a bac

~~~puppet
haproxy::frontend { 'puppet00':
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8140',
mode => 'tcp',
bind_options => 'accept-proxy',
Expand All @@ -272,7 +272,7 @@ If option order is important, pass an array of hashes to the `options` parameter

~~~puppet
haproxy::frontend { 'puppet00':
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8140',
mode => 'tcp',
bind_options => 'accept-proxy',
Expand Down Expand Up @@ -397,7 +397,7 @@ class and uses `haproxy::instance` to add an additional instance called
haproxy::listen { 'puppet00':
instance => 'haproxy',
collect_exported => false,
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8800',
}
Expand All @@ -411,7 +411,7 @@ class and uses `haproxy::instance` to add an additional instance called
haproxy::listen { 'puppet00':
instance => 'beta',
collect_exported => false,
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '9900',
}
~~~
Expand All @@ -430,7 +430,7 @@ The second uses a custom package.
section_name => 'puppet00',
instance => 'group1',
collect_exported => false,
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '8800',
}
haproxy::instance { 'group2': }
Expand All @@ -444,7 +444,7 @@ The second uses a custom package.
section_name => 'puppet00',
instance => 'group2',
collect_exported => false,
ipaddress => $::ipaddress,
ipaddress => $facts['networking']['ip'],
ports => '9900',
}
~~~
Expand Down
9 changes: 7 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$config_dir = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
$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,
$config_validate_cmd = $haproxy::config_validate_cmd
$config_validate_cmd = $haproxy::config_validate_cmd,
# lint:endignore
) {
if $caller_module_name != $module_name {
Expand All @@ -28,7 +28,12 @@
warning("${module_name}: The \$merge_options parameter will default to true in the next major release. Please review the documentation regarding the implications.") # lint:ignore:140chars
}

if $haproxy::params::manage_config_dir {
if defined(Class['haproxy']) {
$manage_config_dir = $haproxy::manage_config_dir
} else {
$manage_config_dir = $haproxy::params::manage_config_dir
}
if $manage_config_dir {
if $config_dir != undef {
file { $config_dir:
ensure => directory,
Expand Down

0 comments on commit 24049ec

Please sign in to comment.