Skip to content

Commit

Permalink
LOAD_BALANCER: Move defines to separate namespaced files
Browse files Browse the repository at this point in the history
  • Loading branch information
mickenordin committed Oct 24, 2023
1 parent 0aed680 commit c418076
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 47 deletions.
49 changes: 2 additions & 47 deletions manifests/frontend/load_balancer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
notify => Sunet::Exabgp['load_balancer'],
}

configure_peers { 'peers': router_id => $router_id, peers => $config['load_balancer']['peers'] }
sunet::frontend::load_balancer::configure_peers { 'peers': router_id => $router_id, peers => $config['load_balancer']['peers'] }

configure_websites2 { 'websites':
sunet::frontend::load_balancer::configure_websites2 { 'websites':
websites => $config['load_balancer']['websites2'],
basedir => $basedir,
confdir => $confdir,
Expand Down Expand Up @@ -101,48 +101,3 @@
}
}

define sysctl_ip_nonlocal_bind() {
# Allow haproxy to bind() to a service IP address even if it haven't actually
# been set up on an interface yet
augeas { 'frontend_ip_nonlocal_bind_config':
context => '/files/etc/sysctl.d/10-sunet-frontend-ip-non-local-bind.conf',
changes => [
'set net.ipv4.ip_nonlocal_bind 1',
'set net.ipv6.ip_nonlocal_bind 1',
],
notify => Exec['reload_sysctl_10-sunet-frontend-ip-non-local-bind.conf'],
}

exec { 'reload_sysctl_10-sunet-frontend-ip-non-local-bind.conf':
command => '/sbin/sysctl -p /etc/sysctl.d/10-sunet-frontend-ip-non-local-bind.conf',
refreshonly => true,
}
}

define configure_peers($router_id, $peers)
{
$defaults = {
router_id => $router_id,
}
create_resources('sunet::frontend::load_balancer::peer', $peers, $defaults)
}

define configure_websites($websites, $basedir, $confdir)
{
create_resources('sunet::frontend::load_balancer::website', $websites, {
'basedir' => $basedir,
'confdir' => $confdir,
})
}

define configure_websites2($websites, $basedir, $confdir, $scriptdir)
{
each($websites) | $site, $config | {
create_resources('sunet::frontend::load_balancer::website2', {$site => {}}, {
'basedir' => $basedir,
'confdir' => $confdir,
'scriptdir' => $scriptdir,
'config' => $config,
})
}
}
8 changes: 8 additions & 0 deletions manifests/frontend/load_balancer/configure_peers.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
define sunet::frontend::load_balancer::configure_peers($router_id, $peers)
{
$defaults = {
router_id => $router_id,
}
create_resources('sunet::frontend::load_balancer::peer', $peers, $defaults)
}

9 changes: 9 additions & 0 deletions manifests/frontend/load_balancer/configure_websites.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

define sunet::frontend::load_balancer::configure_websites($websites, $basedir, $confdir)
{
create_resources('sunet::frontend::load_balancer::website', $websites, {
'basedir' => $basedir,
'confdir' => $confdir,
})
}

12 changes: 12 additions & 0 deletions manifests/frontend/load_balancer/configure_websites2.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

define sunet::frontend::load_balancer::configure_websites2($websites, $basedir, $confdir, $scriptdir)
{
each($websites) | $site, $config | {
create_resources('sunet::frontend::load_balancer::website2', {$site => {}}, {
'basedir' => $basedir,
'confdir' => $confdir,
'scriptdir' => $scriptdir,
'config' => $config,
})
}
}
18 changes: 18 additions & 0 deletions manifests/frontend/load_balancer/sysctl_ip_nonlocal_bind.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

define sunet::frontend::load_balancer::sysctl_ip_nonlocal_bind() {
# Allow haproxy to bind() to a service IP address even if it haven't actually
# been set up on an interface yet
augeas { 'frontend_ip_nonlocal_bind_config':
context => '/files/etc/sysctl.d/10-sunet-frontend-ip-non-local-bind.conf',
changes => [
'set net.ipv4.ip_nonlocal_bind 1',
'set net.ipv6.ip_nonlocal_bind 1',
],
notify => Exec['reload_sysctl_10-sunet-frontend-ip-non-local-bind.conf'],
}

exec { 'reload_sysctl_10-sunet-frontend-ip-non-local-bind.conf':
command => '/sbin/sysctl -p /etc/sysctl.d/10-sunet-frontend-ip-non-local-bind.conf',
refreshonly => true,
}
}

0 comments on commit c418076

Please sign in to comment.