Skip to content

Commit c84ec3a

Browse files
committed
adjust the service for each os type and correct the control 10
Signed-off-by: Patrick Münch <patrick.muench1111@gmail.com>
1 parent e52d00e commit c84ec3a

File tree

1 file changed

+43
-10
lines changed

1 file changed

+43
-10
lines changed

controls/postgres_spec.rb

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,37 @@
6666
impact 1.0
6767
title 'Postgresql should be running'
6868
desc 'Postgresql should be running.'
69-
describe service(postgres.service) do
70-
it { should be_installed }
71-
it { should be_running }
72-
it { should be_enabled }
69+
case os[:name]
70+
when 'ubuntu'
71+
case os[:release]
72+
when '12.04'
73+
describe service(postgres.service) do
74+
it { should be_installed }
75+
it { should be_running }
76+
it { should be_enabled }
77+
end
78+
when '16.04'
79+
describe systemd_service(postgres.service) do
80+
it { should be_installed }
81+
it { should be_running }
82+
it { should be_enabled }
83+
end
84+
end
85+
when 'redhat', 'centos', 'oracle'
86+
case os[:release]
87+
when /6\./
88+
describe runit_service(postgres.service) do
89+
it { should be_installed }
90+
it { should be_running }
91+
it { should be_enabled }
92+
end
93+
when /7\./
94+
describe systemd_service(postgres.service) do
95+
it { should be_installed }
96+
it { should be_running }
97+
it { should be_enabled }
98+
end
99+
end
73100
end
74101
end
75102

@@ -91,8 +118,14 @@
91118
impact 1.0
92119
title 'Run one postgresql instance per operating system'
93120
desc 'Only one postgresql database instance must be running on an operating system instance (both physical HW or virtualized).'
94-
describe command('ps aux | grep \'postgres -D\' | grep -v grep | wc -l') do
95-
its('stdout') { should match(/^1/) }
121+
if os[:family] == 'debian'
122+
describe processes('postgres') do
123+
its('list.length') { should eq 1 }
124+
end
125+
elsif os[:family] == 'redhat'
126+
describe processes('postmaster') do
127+
its('list.length') { should eq 1 }
128+
end
96129
end
97130
end
98131

@@ -162,14 +195,14 @@
162195
it { should be_directory }
163196
it { should be_owned_by USER }
164197
it { should be_readable.by('owner') }
165-
it { should be_readable.by('group') }
166-
it { should be_readable.by('other') }
198+
it { should_not be_readable.by('group') }
199+
it { should_not be_readable.by('other') }
167200
it { should be_writable.by('owner') }
168201
it { should_not be_writable.by('group') }
169202
it { should_not be_writable.by('other') }
170203
it { should be_executable.by('owner') }
171-
it { should be_executable.by('group') }
172-
it { should be_executable.by('other') }
204+
it { should_not be_executable.by('group') }
205+
it { should_not be_executable.by('other') }
173206
end
174207
describe file(POSTGRES_CONF_PATH) do
175208
it { should be_file }

0 commit comments

Comments
 (0)