From c12421388f4da2bfe676a6029cf931b1fd01e34c Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Thu, 30 Mar 2023 14:21:02 -0500 Subject: [PATCH] Don't insert the `address` option if not specified. --- manifests/server.pp | 9 +++++++-- spec/classes/server_spec.rb | 4 ++-- templates/header.erb | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/manifests/server.pp b/manifests/server.pp index ca43fa7..01c7c58 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -8,7 +8,7 @@ # class rsync::server( Boolean $use_xinetd = true, - $address = '0.0.0.0', + $address = 'UNSET', $motd_file = 'UNSET', Variant[Enum['UNSET'], Stdlib::Absolutepath] $pid_file = '/var/run/rsyncd.pid', $use_chroot = 'yes', @@ -26,12 +26,17 @@ if $use_xinetd { include xinetd xinetd::service { 'rsync': - bind => $address, port => '873', server => '/usr/bin/rsync', server_args => "--daemon --config ${conf_file}", require => Package['rsync'], } + + if ($address != 'UNSET') { + Xinetd::Service['rsync'] { + bind => $address, + } + } } else { # Manage the installation of the rsyncd package? diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 837b038..d741cce 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -9,12 +9,11 @@ describe 'when using default params' do it { is_expected.to contain_class('xinetd') - is_expected.to contain_xinetd__service('rsync').with(bind: '0.0.0.0') + is_expected.to contain_xinetd__service('rsync').with(port: 873) is_expected.not_to contain_service('rsync') is_expected.not_to contain_file('/etc/rsync-motd') is_expected.to contain_concat__fragment('rsyncd_conf_header').with(order: '00_header') is_expected.to contain_concat__fragment('rsyncd_conf_header').with_content(%r{^use chroot\s*=\s*yes$}) - is_expected.to contain_concat__fragment('rsyncd_conf_header').with_content(%r{^address\s*=\s*0.0.0.0$}) is_expected.to contain_concat__fragment('rsyncd_conf_header').with_content(%r{^pid file\s*=\s*/var/run/rsyncd.pid$}) } end @@ -76,6 +75,7 @@ end it { + is_expected.to contain_xinetd__service('rsync').with(bind: '10.0.0.42') is_expected.to contain_concat__fragment('rsyncd_conf_header').with_content(%r{^address\s*=\s*10.0.0.42$}) } end diff --git a/templates/header.erb b/templates/header.erb index bd7756c..0effa53 100644 --- a/templates/header.erb +++ b/templates/header.erb @@ -10,7 +10,9 @@ use chroot = <%= @use_chroot %> log format = %t %a %m %f %b syslog facility = local3 timeout = 300 +<% if @address != 'UNSET' -%> address = <%= @address %> +<% end -%> <% if @motd_file != 'UNSET' -%> motd file = <%= @motd_file %> <% end -%>