Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] ownership and permissions on conf files #835

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,23 @@

file { '/etc/rabbitmq':
ensure => directory,
owner => '0',
group => '0',
mode => '0755',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '2755',
}

file { '/etc/rabbitmq/ssl':
ensure => directory,
owner => '0',
group => '0',
mode => '0755',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '2750',
}

file { 'rabbitmq.config':
ensure => file,
path => $config_path,
content => template($config),
owner => '0',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '0640',
}
Expand All @@ -171,7 +171,7 @@
ensure => file,
path => $env_config_path,
content => template($env_config),
owner => '0',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '0640',
}
Expand All @@ -180,7 +180,7 @@
ensure => file,
path => $inetrc_config_path,
content => template($inetrc_config),
owner => '0',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '0640',
}
Expand All @@ -190,7 +190,7 @@
ensure => file,
path => '/etc/rabbitmq/enabled_plugins',
content => template('rabbitmq/enabled_plugins.erb'),
owner => '0',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '0640',
require => File['/etc/rabbitmq'],
Expand All @@ -202,7 +202,7 @@
ensure => file,
path => '/etc/rabbitmq/rabbitmqadmin.conf',
content => template('rabbitmq/rabbitmqadmin.conf.erb'),
owner => '0',
owner => $rabbitmq_user,
group => $rabbitmq_group,
mode => '0640',
require => File['/etc/rabbitmq'],
Expand Down
13 changes: 13 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ class { 'erlang': epel_enable => true}
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end

describe file('/etc/rabbitmq') do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'rabbitmq' }
it { is_expected.to be_grouped_into 'rabbitmq' }
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think this is the right place for these to live?
seems sensible to test these in the acceptance tests one way or another, I think, right?


describe file('/etc/rabbitmq/ssl') do
it { is_expected.to be_directory }
it { is_expected.to be_owned_by 'rabbitmq' }
it { is_expected.to be_grouped_into 'rabbitmq' }
it { is_expected.not_to be_readable.by('others') }
end
end

context 'disable and stop service' do
Expand Down
17 changes: 15 additions & 2 deletions spec/classes/rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,21 +310,34 @@
it {
is_expected.to contain_file('/etc/rabbitmq').with(
'ensure' => 'directory',
'mode' => '0755'
'owner' => 'rabbitmq',
'group' => 'rabbitmq',
'mode' => '2755'
)
}
end

describe 'manages configuration file correctly' do
it {
is_expected.to contain_file('rabbitmq.config').with(
'owner' => '0',
'owner' => 'rabbitmq',
'group' => 'rabbitmq',
'mode' => '0640'
)
}
end

describe 'manages SSL directory correctly' do
it {
is_expected.to contain_file('/etc/rabbitmq/ssl').with(
'ensure' => 'directory',
'owner' => 'rabbitmq',
'group' => 'rabbitmq',
'mode' => '2750'
)
}
end

describe 'does not contain pre-ranch settings with default config' do
it do
is_expected.to contain_file('rabbitmq.config'). \
Expand Down