From b3576e78bfaeff7644dc37614613cef2df0661f0 Mon Sep 17 00:00:00 2001 From: Joel Capitao Date: Tue, 8 Jun 2021 17:25:31 +0200 Subject: [PATCH] Add 'rsync_use_xinetd' as argument to swift::ringserver Since in RHEL/CentOS >= 8 rsyncd systemd unit is shipped in a different package (rsync-dameon), we need to be able to not use xinetd to manage rsync service. The dependency on rsync-daemon for RHEL/CentOS >= 8 is handled in puppet-rsync with [1]. [1] https://github.com/puppetlabs/puppetlabs-rsync/pull/139/files Conflicts: manifests/params.pp Resolved conflict caused by 5b0745101a9af363e367ef301728541921a5a70d . Closes-Bug: #1930855 Change-Id: I85abf3811d61fa8bfc0a1607818d6495549b5a6b (cherry picked from commit 053a3a2a56723e0ec43d1855ac7615657a4de8f0) --- manifests/params.pp | 6 +++++ manifests/ringserver.pp | 15 +++++++++--- manifests/storage.pp | 13 +++++++---- manifests/storage/all.pp | 12 +++++++++- ...tch_rsync_use_xinetd-a3c857e5ef13b0a8.yaml | 8 +++++++ spec/classes/swift_ringserver_spec.rb | 23 +++++++------------ 6 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 releasenotes/notes/switch_rsync_use_xinetd-a3c857e5ef13b0a8.yaml diff --git a/manifests/params.pp b/manifests/params.pp index 7093c2bf..277bf49e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -36,6 +36,7 @@ class swift::params { $account_reaper_service_name = 'swift-account-reaper' $account_replicator_service_name = 'swift-account-replicator' $ceilometermiddleware_package_name = "python${pyvers}-ceilometermiddleware" + $xinetd_available = true } 'RedHat': { $package_name = 'openstack-swift' @@ -62,6 +63,11 @@ class swift::params { $account_reaper_service_name = 'openstack-swift-account-reaper' $account_replicator_service_name = 'openstack-swift-account-replicator' $ceilometermiddleware_package_name = "python${pyvers}-ceilometermiddleware" + if (Integer.new($::os['release']['major']) > 8) { + $xinetd_available = false + } else { + $xinetd_available = true + } } default: { fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, \ diff --git a/manifests/ringserver.pp b/manifests/ringserver.pp index d0b939b4..0595b850 100644 --- a/manifests/ringserver.pp +++ b/manifests/ringserver.pp @@ -11,6 +11,10 @@ # (optional) maximum connections to rsync server # Defaults to 5 # +# [*rsync_use_xinetd*] +# (optional) Override whether to use xinetd to manage rsync service +# Defaults to swift::params::xinetd_available +# # == Dependencies # # Class['swift'] @@ -27,15 +31,20 @@ # class swift::ringserver( $local_net_ip, - $max_connections = 5 -) { + $max_connections = 5, + $rsync_use_xinetd = $::swift::params::xinetd_available, +) inherits swift::params { include swift::deps Class['swift::ringbuilder'] -> Class['swift::ringserver'] + if $rsync_use_xinetd and ! $::swift::params::xinetd_available { + fail('xinetd is not available in this distro') + } + if !defined(Class['rsync::server']) { class { 'rsync::server': - use_xinetd => true, + use_xinetd => $rsync_use_xinetd, address => $local_net_ip, use_chroot => 'no', } diff --git a/manifests/storage.pp b/manifests/storage.pp index 554cc585..2400627a 100644 --- a/manifests/storage.pp +++ b/manifests/storage.pp @@ -8,8 +8,9 @@ # [*storage_local_net_ip*] ip address that the swift servers should # bind to. Required. # -# [*rsync_use_xinetd*] indicate if xinetd should be used to manage -# rsync service, Default to True. +# [*rsync_use_xinetd*] +# (optional) Override whether to use xinetd to manage rsync service +# Defaults to swift::params::xinetd_available # # == Dependencies # @@ -25,11 +26,15 @@ # class swift::storage( $storage_local_net_ip, - $rsync_use_xinetd = true, -) { + $rsync_use_xinetd = $::swift::params::xinetd_available, +) inherits swift::params { include swift::deps + if $rsync_use_xinetd and ! $::swift::params::xinetd_available { + fail('xinetd is not available in this distro') + } + if !defined(Class['rsync::server']){ class{ 'rsync::server': use_xinetd => $rsync_use_xinetd, diff --git a/manifests/storage/all.pp b/manifests/storage/all.pp index a6b63a83..60be8b74 100644 --- a/manifests/storage/all.pp +++ b/manifests/storage/all.pp @@ -122,6 +122,10 @@ # (optional) maximum number of simultaneous connections allowed for rsync. # Defaults to 25. # +# [*rsync_use_xinetd*] +# (optional) Override whether to use xinetd to manage rsync service +# Defaults to swift::params::xinetd_available +# class swift::storage::all( $storage_local_net_ip, $devices = '/srv/node', @@ -152,7 +156,8 @@ class swift::storage::all( $object_server_mb_per_sync = 512, $splice = false, $max_connections = 25, -) { + $rsync_use_xinetd = $::swift::params::xinetd_available, +) inherits swift::params { include swift::deps @@ -171,8 +176,13 @@ from 6001 to 6201 and will be changed in a later release') from 6002 to 6202 and will be changed in a later release') } + if $rsync_use_xinetd and ! $::swift::params::xinetd_available { + fail('xinetd is not available in this distro') + } + class { 'swift::storage': storage_local_net_ip => $storage_local_net_ip, + rsync_use_xinetd => $rsync_use_xinetd, } Swift::Storage::Server { diff --git a/releasenotes/notes/switch_rsync_use_xinetd-a3c857e5ef13b0a8.yaml b/releasenotes/notes/switch_rsync_use_xinetd-a3c857e5ef13b0a8.yaml new file mode 100644 index 00000000..bc224879 --- /dev/null +++ b/releasenotes/notes/switch_rsync_use_xinetd-a3c857e5ef13b0a8.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + The new rsync_use_xinetd parameter has been added to the following classes, + to add the ability to enable/disable usage of xinetd to run rsync server. + + - ``swift::ringserver`` + - ``swift::storage::all`` diff --git a/spec/classes/swift_ringserver_spec.rb b/spec/classes/swift_ringserver_spec.rb index dd4b180e..4b4370df 100644 --- a/spec/classes/swift_ringserver_spec.rb +++ b/spec/classes/swift_ringserver_spec.rb @@ -4,6 +4,13 @@ require 'spec_helper' WebMock.disable_net_connect!(:allow => "169.254.169.254") describe 'swift::ringserver' do + let :params do + { :local_net_ip => '127.0.0.1', + :max_connections => 5, + :rsync_use_xinetd => true, + } + end + shared_examples 'swift::ringserver' do context 'when storage.pp was already included' do let :pre_condition do @@ -12,13 +19,6 @@ describe 'swift::ringserver' do include swift::ringbuilder" end - let :params do - { - :local_net_ip => '127.0.0.1', - :max_connections => 5 - } - end - it 'does not create the rsync::server class' do is_expected.to compile end @@ -41,13 +41,6 @@ describe 'swift::ringserver' do include swift::ringbuilder" end - let :params do - { - :local_net_ip => '127.0.0.1', - :max_connections => 5 - } - end - it 'does create the rsync::server class' do is_expected.to contain_class('rsync::server').with({ 'use_xinetd' => 'true', @@ -77,7 +70,7 @@ describe 'swift::ringserver' do facts.merge(OSDefaults.get_facts()) end - it_configures 'swift::ringserver' + it_behaves_like 'swift::ringserver' end end end