From 7a10c64995530d782139c05bbe4955ec1e4a180b Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 25 Sep 2019 11:08:22 +0200 Subject: [PATCH] fd: also use the grep in public_addresses to learn if we support v4/v6 --- modules/bacula/manifests/init.pp | 5 +++++ modules/bacula/manifests/storage.pp | 4 ---- modules/bacula/templates/bacula-fd.conf.erb | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/bacula/manifests/init.pp b/modules/bacula/manifests/init.pp index eee682f27..013bcf321 100644 --- a/modules/bacula/manifests/init.pp +++ b/modules/bacula/manifests/init.pp @@ -1,6 +1,8 @@ # bacula class -- defines all the variables we care about in our bacula deployment # # @param public_addresses this host's public IP addresses. The ones it connects out from and is reachable from outsite. +# @param has_ipv4 daemons should listen on ipv4 +# @param has_ipv6 daemons should listen on ipv6 class bacula ( String $bacula_operator_email = 'bacula-reports@admin.debian.org', @@ -14,6 +16,9 @@ class bacula ( String $tag_bacula_dsa_client_list = 'bacula::dsa::clientlist', Array[Stdlib::IP::Address] $public_addresses = $base::public_addresses, + + 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 }, ) { file { '/usr/local/sbin/bacula-idle-restart': mode => '0555', diff --git a/modules/bacula/manifests/storage.pp b/modules/bacula/manifests/storage.pp index ca41a4637..0a445e0fe 100644 --- a/modules/bacula/manifests/storage.pp +++ b/modules/bacula/manifests/storage.pp @@ -6,8 +6,6 @@ # @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', @@ -15,8 +13,6 @@ 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 { package { 'bacula-sd': diff --git a/modules/bacula/templates/bacula-fd.conf.erb b/modules/bacula/templates/bacula-fd.conf.erb index 5e07c9fe6..eeb578881 100644 --- a/modules/bacula/templates/bacula-fd.conf.erb +++ b/modules/bacula/templates/bacula-fd.conf.erb @@ -11,7 +11,7 @@ FileDaemon { # 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. @@ -19,7 +19,7 @@ FileDaemon { port = <%= @port_fd %> } <%- end -%> - <%- scope.lookupvar('deprecated::nodeinfo')['misc']['v6_ldap'].each do |addr| -%> + <%- if @has_ipv6 -%> ipv6 = { addr = <%= addr %> port = <%= @port_fd %> -- 2.20.1