|
66 | 66 | impact 1.0
|
67 | 67 | title 'Postgresql should be running'
|
68 | 68 | 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 | + # describe service(postgres.service) do |
| 70 | + # it { should be_installed } |
| 71 | + # it { should be_running } |
| 72 | + # it { should be_enabled } |
| 73 | + # end |
| 74 | + case os[:name] |
| 75 | + when 'ubuntu' |
| 76 | + case os[:release] |
| 77 | + when '12.04' |
| 78 | + describe command('/etc/init.d/postgresql status') do |
| 79 | + its('stdout') { should include 'online' } |
| 80 | + end |
| 81 | + when '14.04' |
| 82 | + describe command('service postgresql status') do |
| 83 | + its('stdout') { should include 'online' } |
| 84 | + end |
| 85 | + when '16.04' |
| 86 | + describe systemd_service(postgres.service) do |
| 87 | + it { should be_installed } |
| 88 | + it { should be_running } |
| 89 | + it { should be_enabled } |
| 90 | + end |
| 91 | + end |
| 92 | + when 'debian' |
| 93 | + case os[:release] |
| 94 | + when /7\./ |
| 95 | + describe command('/etc/init.d/postgresql status') do |
| 96 | + its('stdout') { should include 'Running' } |
| 97 | + end |
| 98 | + end |
| 99 | + when 'redhat', 'centos', 'oracle', 'fedora' |
| 100 | + case os[:release] |
| 101 | + when /6\./ |
| 102 | + describe command('/etc/init.d/postgresql-9.4 status') do |
| 103 | + its('stdout') { should include 'running' } |
| 104 | + end |
| 105 | + when /7\./ |
| 106 | + describe command('ps aux | awk /\'bin\/postgres\'/ | wc -l') do |
| 107 | + its('stdout') { should include '1' } |
| 108 | + end |
| 109 | + end |
73 | 110 | end
|
74 | 111 | end
|
75 | 112 |
|
|
78 | 115 | title 'Use stable postgresql version'
|
79 | 116 | desc 'Use only community or commercially supported version of the PostgreSQL software. Do not use RC, DEVEL oder BETA versions in a production environment.'
|
80 | 117 | describe command('psql -V') do
|
81 |
| - its('stdout') { should match(/9.[2-5]/) } |
| 118 | + its('stdout') { should match(/9.[1-5]/) } |
82 | 119 | end
|
83 | 120 | describe command('psql -V') do
|
84 | 121 | its('stdout') { should_not match(/RC/) }
|
|
91 | 128 | impact 1.0
|
92 | 129 | title 'Run one postgresql instance per operating system'
|
93 | 130 | 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/) } |
| 131 | + pg_command = 'postgres' |
| 132 | + pg_command = 'postmaster' if os.redhat? && os.release.include?('6.') |
| 133 | + describe processes(pg_command) do |
| 134 | + its('list.length') { should eq 1 } |
96 | 135 | end
|
97 | 136 | end
|
98 | 137 |
|
|
162 | 201 | it { should be_directory }
|
163 | 202 | it { should be_owned_by USER }
|
164 | 203 | it { should be_readable.by('owner') }
|
165 |
| - it { should be_readable.by('group') } |
166 |
| - it { should be_readable.by('other') } |
| 204 | + it { should_not be_readable.by('group') } |
| 205 | + it { should_not be_readable.by('other') } |
167 | 206 | it { should be_writable.by('owner') }
|
168 | 207 | it { should_not be_writable.by('group') }
|
169 | 208 | it { should_not be_writable.by('other') }
|
170 | 209 | it { should be_executable.by('owner') }
|
171 |
| - it { should be_executable.by('group') } |
172 |
| - it { should be_executable.by('other') } |
| 210 | + it { should_not be_executable.by('group') } |
| 211 | + it { should_not be_executable.by('other') } |
173 | 212 | end
|
174 | 213 | describe file(POSTGRES_CONF_PATH) do
|
175 | 214 | it { should be_file }
|
|
0 commit comments