Skip to content

Commit

Permalink
Allow to setup multiple listening addresses
Browse files Browse the repository at this point in the history
By default, the daemons listen on the system IPv4 address only.  The
year is 2022, we can listen on IPv6 too :-)
  • Loading branch information
smortex committed Jun 28, 2022
1 parent 50ed3f1 commit a4ef88d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
5 changes: 4 additions & 1 deletion manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
Optional[String] $default_pool_inc,
Optional[String] $default_pool_diff,
Integer $port = 9102,
Optional[String] $listen_address = $facts['networking']['ip'],
Variant[String,Array[String[1]]] $listen_address = [
$facts['networking']['ip'],
$facts['networking']['ip6'],
].filter |$ip| { $ip },
String $password = 'secret',
Integer $max_concurrent_jobs = 2,
String $director_name = $bacula::director_name,
Expand Down
5 changes: 4 additions & 1 deletion manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
String $group = $bacula::bacula_group,
String $homedir = $bacula::homedir,
Optional[String] $job_tag = $bacula::job_tag,
Optional[String] $listen_address = $facts['networking']['ip'],
Variant[String,Array[String[1]]] $listen_address = [
$facts['networking']['ip'],
$facts['networking']['ip6'],
].filter |$ip| { $ip },
Integer $max_concurrent_jobs = 20,
Boolean $manage_defaults = true,
String $password = 'secret',
Expand Down
5 changes: 4 additions & 1 deletion manifests/storage.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
String $director_name = $bacula::director_name,
String $group = $bacula::bacula_group,
String $homedir = $bacula::homedir,
Optional[String] $listen_address = $facts['networking']['ip'],
Variant[String,Array[String[1]]] $listen_address = [
$facts['networking']['ip'],
$facts['networking']['ip6'],
].filter |$ip| { $ip },
Integer $maxconcurjobs = 5,
String $media_type = 'File',
String $password = 'secret',
Expand Down
4 changes: 3 additions & 1 deletion templates/_listen.epp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<%
|
String $listen_address,
Array[String[1]] $listen_addresses,
Optional[Integer] $port,
|
-%>
<%- $listen_addresses.each |$listen_address| { -%>
<%= $listen_address ? {
Stdlib::IP::Address::V4::Nosubnet => 'ipv4',
Stdlib::IP::Address::V6::Nosubnet => 'ipv6',
Expand All @@ -14,3 +15,4 @@
port = <%= $port %>;
<% } -%>
}
<%- } -%>
4 changes: 2 additions & 2 deletions templates/bacula-dir-header.epp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Director { # define myself
Name = <%= $clientcert %>-dir
<% if $bacula::director::listen_address { -%>
<% unless $bacula::director::listen_address.empty { -%>
DirAddresses = {
<%= epp('bacula/_listen.epp', { listen_address => $bacula::director::listen_address, port => $bacula::director::port }) %>
<%= epp('bacula/_listen.epp', { listen_addresses => [$bacula::director::listen_address].flatten, port => $bacula::director::port }) %>
}
<% } -%>
QueryFile = "/etc/bacula/scripts/query.sql"
Expand Down
4 changes: 2 additions & 2 deletions templates/bacula-fd-header.epp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Director {

FileDaemon {
Name = <%= $bacula::client::client %>-fd
<% if $bacula::client::listen_address { -%>
<% unless $bacula::client::listen_address.empty { -%>
FDAddresses = {
<%= epp('bacula/_listen.epp', { listen_address => $bacula::client::listen_address, port => $bacula::client::port }) -%>
<%= epp('bacula/_listen.epp', { listen_addresses => [$bacula::client::listen_address].flatten, port => $bacula::client::port }) -%>
}
<% } -%>
WorkingDirectory = <%= $bacula::client::homedir %>
Expand Down
4 changes: 2 additions & 2 deletions templates/bacula-sd-header.epp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Storage {
Name = <%= $clientcert %>-sd
WorkingDirectory = <%= $bacula::storage::homedir %>
Pid Directory = <%= $bacula::storage::rundir %>
<% if $bacula::storage::listen_address { -%>
<% unless $bacula::storage::listen_address.empty { -%>
SDAddresses = {
<%= epp('bacula/_listen.epp', { listen_address => $bacula::storage::listen_address, port => $bacula::storage::port }) -%>
<%= epp('bacula/_listen.epp', { listen_addresses => [$bacula::storage::listen_address].flatten, port => $bacula::storage::port }) -%>
}
<% } -%>
<%= epp('bacula/_tls_server.epp') -%>
Expand Down

0 comments on commit a4ef88d

Please sign in to comment.