test(inspec): move common controls to the share profile
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Overide by Platform
|
||||
pg_port = '5432'
|
||||
pg_port = '5433' if (platform[:family] == 'debian') || (platform[:family] == 'suse')
|
||||
|
||||
control 'Postgres command' do
|
||||
title 'should match desired lines'
|
||||
|
||||
# Can't use `%Q` here due to the `\`
|
||||
describe command("su - postgres -c 'psql -p#{pg_port} -qtc \"\\l+ db2\"'") do
|
||||
its(:stdout) do
|
||||
should match(
|
||||
/db2.*remoteUser.*UTF8.*en_US.UTF-8.*en_US.UTF-8.*my_space/
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
control 'Postgres configuration' do
|
||||
title 'should include the directory'
|
||||
|
||||
describe file('/srv/my_tablespace') do
|
||||
it { should be_directory }
|
||||
it { should be_owned_by 'postgres' }
|
||||
it { should be_grouped_into 'postgres' }
|
||||
its('mode') { should cmp '0700' }
|
||||
end
|
||||
end
|
||||
@@ -1,19 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Overide by Platform
|
||||
service_name = 'postgresql'
|
||||
pg_port = 5432
|
||||
if (platform[:name] == 'centos') && platform[:release].start_with?('6')
|
||||
service_name = 'postgresql-9.6'
|
||||
elsif (platform[:family] == 'debian') || (platform[:family] == 'suse')
|
||||
pg_port = 5433
|
||||
end
|
||||
|
||||
pg_port =
|
||||
case platform[:family]
|
||||
when 'debian', 'suse'
|
||||
5433
|
||||
else
|
||||
5432
|
||||
end
|
||||
|
||||
control 'Postgres service' do
|
||||
impact 0.5
|
||||
title 'should be running and enabled'
|
||||
title 'should be installed, enabled and running'
|
||||
|
||||
describe service(service_name) do
|
||||
it { should be_installed }
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
end
|
||||
|
||||
13
test/integration/default/controls/share.rb
Normal file
13
test/integration/default/controls/share.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# https://docs.chef.io/inspec/profiles/#including-all-controls-from-a-profile
|
||||
# Could use `include_controls` in this scenario
|
||||
# include_controls 'share'
|
||||
|
||||
# https://docs.chef.io/inspec/profiles/#selectively-including-controls-from-a-profile
|
||||
# However, using `require_controls` for more clarity
|
||||
require_controls 'share' do
|
||||
control 'Postgres command'
|
||||
control 'Postgres configuration'
|
||||
# control 'Postgres service'
|
||||
end
|
||||
Reference in New Issue
Block a user