Make RGW deployment idempotent

- Set selinux_ignore_defaults to True for RGW directories otherwise Puppet
  will try to modify SElinux context, different from packaging.
- Update rgw service for systemd

Change-Id: Idea369a3f08be2d6c25913152b63cab5eadb8641
This commit is contained in:
Emilien Macchi 2016-08-30 15:38:58 -04:00 committed by Keith Schincke
parent 309ef4819b
commit b72bf9d6b8
2 changed files with 52 additions and 46 deletions

View File

@ -135,21 +135,24 @@ define ceph::rgw (
# Data directory for radosgw
file { '/var/lib/ceph/radosgw': # missing in redhat pkg
ensure => directory,
mode => '0755',
ensure => directory,
mode => '0755',
selinux_ignore_defaults => true,
}
file { $rgw_data:
ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
ensure => directory,
owner => 'root',
group => 'root',
mode => '0750',
selinux_ignore_defaults => true,
}
# Log file for radosgw (ownership)
file { $log_file:
ensure => present,
owner => $user,
mode => '0640',
ensure => present,
owner => $user,
mode => '0640',
selinux_ignore_defaults => true,
}
# service definition
@ -176,6 +179,7 @@ define ceph::rgw (
start => "systemctl start ceph-radosgw@${name}",
stop => "systemctl stop ceph-radosgw@${name}",
status => "systemctl status ceph-radosgw@${name}",
provider => $::ceph::params::service_provider,
}
} else {
if $rgw_enable {
@ -194,13 +198,6 @@ define ceph::rgw (
}
}
#for RHEL/CentOS7, systemctl needs to reload to pickup the ceph-radosgw init file
if (($::operatingsystem == 'RedHat' or $::operatingsystem == 'CentOS') and (versioncmp($::operatingsystemmajrelease, '7') >= 0))
{
exec { 'systemctl-reload-from-rgw': #needed for the new init file
command => '/usr/bin/systemctl daemon-reload',
}
}
service { "radosgw-${name}":
ensure => $rgw_ensure,
}

View File

@ -53,15 +53,17 @@ describe 'ceph::rgw' do
it { is_expected.to contain_ceph_config('client.radosgw.gateway/rgw_socket_path').with_value('/tmp/radosgw.sock') }
it { is_expected.to contain_file('/var/lib/ceph/radosgw').with({
'ensure' => 'directory',
'mode' => '0755',
'ensure' => 'directory',
'mode' => '0755',
'selinux_ignore_defaults' => true,
})}
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with({
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'selinux_ignore_defaults' => true,
})}
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') }
@ -105,10 +107,11 @@ describe 'ceph::rgw' do
it { is_expected.to contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') }
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( {
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'selinux_ignore_defaults' => true,
} ) }
it { is_expected.to_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') }
@ -148,15 +151,17 @@ describe 'ceph::rgw' do
it { is_expected.to contain_ceph_config('client.radosgw.gateway/rgw_socket_path').with_value('/tmp/radosgw.sock') }
it { is_expected.to contain_file('/var/lib/ceph/radosgw').with({
'ensure' => 'directory',
'mode' => '0755',
'ensure' => 'directory',
'mode' => '0755',
'selinux_ignore_defaults' => true,
})}
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with({
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'selinux_ignore_defaults' => true,
})}
it { is_expected.to contain_service('radosgw-radosgw.gateway') }
@ -198,10 +203,11 @@ describe 'ceph::rgw' do
it { is_expected.to contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') }
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( {
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'selinux_ignore_defaults' => true,
} ) }
it { is_expected.to_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/done') }
@ -241,15 +247,17 @@ describe 'ceph::rgw' do
it { is_expected.to contain_ceph_config('client.radosgw.gateway/rgw_socket_path').with_value('/tmp/radosgw.sock') }
it { is_expected.to contain_file('/var/lib/ceph/radosgw').with({
'ensure' => 'directory',
'mode' => '0755',
'ensure' => 'directory',
'mode' => '0755',
'selinux_ignore_defaults' => true,
})}
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway').with({
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'selinux_ignore_defaults' => true,
})}
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/sysvinit') }
@ -293,10 +301,11 @@ describe 'ceph::rgw' do
it { is_expected.to contain_ceph_config('client.radosgw.custom/user').with_value('wwwuser') }
it { is_expected.to contain_file('/var/lib/ceph/radosgw/ceph-radosgw.custom').with( {
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'ensure' => 'directory',
'owner' => 'root',
'group' => 'root',
'mode' => '0750',
'selinux_ignore_defaults' => true,
} ) }
it { is_expected.to_not contain_file('/var/lib/ceph/radosgw/ceph-radosgw.gateway/sysvinit') }