From 5419a3761db7fb6dbf42a0097275f9723f7fa910 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 25 Sep 2019 00:00:29 +0200 Subject: [PATCH] Move ipv[46] check into the manifest --- modules/bacula/manifests/storage.pp | 4 ++++ modules/bacula/templates/bacula-sd.conf.erb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/bacula/manifests/storage.pp b/modules/bacula/manifests/storage.pp index 4ed59928c..2b8ed3f9e 100644 --- a/modules/bacula/manifests/storage.pp +++ b/modules/bacula/manifests/storage.pp @@ -6,6 +6,8 @@ # @param port_sd port for the sd to listen on # @param storage_name bacula name of this sd instance # @param storage_address address of this sd instance that other instances should connect to (dns name) +# @param has_ipv4 SD should listen on ipv4 +# @param has_ipv6 SD should listen on ipv6 class bacula::storage ( String $backup_path = '/srv/bacula', String $filestor_device = 'FileStorage', @@ -13,6 +15,8 @@ class bacula::storage ( Integer $port_sd = 9103, String $storage_name = "${::fqdn}-sd", Stdlib::Host $storage_address = $::fqdn, + Boolean $has_ipv4 = $bacula::public_addresses.any |$addr| { $addr =~ Stdlib::IP::Address::V4 }, + Boolean $has_ipv6 = $bacula::public_addresses.any |$addr| { $addr =~ Stdlib::IP::Address::V6 }, ) inherits bacula { $storage_secret = hkdf('/etc/puppet/secret', "bacula-sd-${::fqdn}") diff --git a/modules/bacula/templates/bacula-sd.conf.erb b/modules/bacula/templates/bacula-sd.conf.erb index c15203907..0a0ef7998 100644 --- a/modules/bacula/templates/bacula-sd.conf.erb +++ b/modules/bacula/templates/bacula-sd.conf.erb @@ -10,7 +10,7 @@ Storage { # bacula, on Debian 9 (stretch), does not resolve a single name # to both v4 and v6 addresses. Se we can't just say # ip = { addr = }. Boo. - <%- if scope.lookupvar('deprecated::nodeinfo')['misc']['has_v4_ldap'] -%> + <%- if @has_ipv4 -%> ipv4 = { # use the hostname rather than the IP address from LDAP, # as /etc/hosts might have a better answer in case of natted hosts. @@ -18,7 +18,7 @@ Storage { port = <%= @port_sd %> } <%- end -%> - <%- if scope.lookupvar('deprecated::nodeinfo')['misc']['has_v6_ldap'] -%> + <%- if @has_ipv6 -%> ipv6 = { addr = <%= @storage_address %> port = <%= @port_sd %> -- 2.20.1