|
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 } |
| 73 | + # end |
69 | 74 | case os[:name] |
70 | 75 | when 'ubuntu' |
71 | 76 | case os[:release] |
72 | 77 | when '12.04' |
73 | | - describe service(postgres.service) do |
74 | | - it { should be_installed } |
75 | | - it { should be_running } |
76 | | - it { should be_enabled } |
| 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' } |
77 | 84 | end |
78 | 85 | when '16.04' |
79 | 86 | describe systemd_service(postgres.service) do |
|
82 | 89 | it { should be_enabled } |
83 | 90 | end |
84 | 91 | end |
85 | | - when 'redhat', 'centos', 'oracle' |
| 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' |
86 | 100 | case os[:release] |
87 | 101 | when /6\./ |
88 | | - describe runit_service(postgres.service) do |
89 | | - it { should be_installed } |
90 | | - it { should be_running } |
91 | | - it { should be_enabled } |
| 102 | + describe command('/etc/init.d/postgresql-9.4 status') do |
| 103 | + its('stdout') { should include 'running' } |
92 | 104 | end |
93 | 105 | when /7\./ |
94 | | - describe systemd_service(postgres.service) do |
95 | | - it { should be_installed } |
96 | | - it { should be_running } |
97 | | - it { should be_enabled } |
| 106 | + describe command('ps aux | awk /\'bin\/postgres\'/ | wc -l') do |
| 107 | + its('stdout') { should include '1' } |
98 | 108 | end |
99 | 109 | end |
100 | 110 | end |
|
105 | 115 | title 'Use stable postgresql version' |
106 | 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.' |
107 | 117 | describe command('psql -V') do |
108 | | - its('stdout') { should match(/9.[2-5]/) } |
| 118 | + its('stdout') { should match(/9.[1-5]/) } |
109 | 119 | end |
110 | 120 | describe command('psql -V') do |
111 | 121 | its('stdout') { should_not match(/RC/) } |
|
118 | 128 | impact 1.0 |
119 | 129 | title 'Run one postgresql instance per operating system' |
120 | 130 | desc 'Only one postgresql database instance must be running on an operating system instance (both physical HW or virtualized).' |
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 |
| 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 } |
129 | 135 | end |
130 | 136 | end |
131 | 137 |
|
|
0 commit comments