Skip to content
Snippets Groups Projects
Unverified Commit 22140963 authored by Imran Iqbal's avatar Imran Iqbal
Browse files

test(inspec): move common controls to the `share` profile

parent 27473b98
No related branches found
No related tags found
No related merge requests found
# frozen_string_literal: true # frozen_string_literal: true
# Overide by Platform
service_name = 'postgresql' service_name = 'postgresql'
pg_port = 5432
if (platform[:name] == 'centos') && platform[:release].start_with?('6') pg_port =
service_name = 'postgresql-9.6' case platform[:family]
elsif (platform[:family] == 'debian') || (platform[:family] == 'suse') when 'debian', 'suse'
pg_port = 5433 5433
else
5432
end end
control 'Postgres service' do control 'Postgres service' do
impact 0.5 impact 0.5
title 'should be running and enabled' title 'should be installed, enabled and running'
describe service(service_name) do describe service(service_name) do
it { should be_installed }
it { should be_enabled } it { should be_enabled }
it { should be_running } it { should be_running }
end end
......
# 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
# frozen_string_literal: true
service_name =
case platform[:family]
when 'redhat', 'fedora', 'suse'
case system.platform[:release]
when 'tumbleweed'
'postgresql'
else
'postgresql-13'
end
else
'postgresql'
end
pg_port =
case platform[:family]
when 'debian', 'suse'
5433
else
5432
end
control 'Postgres service' do
impact 0.5
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
describe port(pg_port) do
it { should be_listening }
end
end
# 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment