Skip to content

Commit c185f6b

Browse files
author
Himani Anil Deshpande
committed
Use disable_services.rb recipe to disable dynamic services we want using DevSettings
1 parent 45431e6 commit c185f6b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

cookbooks/aws-parallelcluster-platform/recipes/install/disable_services.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@
2727
service 'log4j-cve-2021-44228-hotpatch' do
2828
action %i(disable stop mask)
2929
end unless on_docker?
30+
31+
# Disable services if node['cluster']['disable_services'] is provided
32+
if node['cluster']['disable_services']
33+
node['cluster']['disable_services'].split(" ").each do | service_name |
34+
service service_name do
35+
action %i(disable stop mask)
36+
end unless on_docker?
37+
end
38+
end
39+

cookbooks/aws-parallelcluster-platform/spec/unit/recipes/disable_services_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
require 'spec_helper'
22

3+
DISABLE_SERVICE_NAME = 'service_name1 service_name_2'.freeze
4+
35
describe 'aws-parallelcluster-platform::disable_services' do
46
for_all_oses do |platform, version|
57
context "on #{platform}#{version}" do
8+
69
cached(:chef_run) do
7-
runner(platform: platform, version: version).converge(described_recipe)
10+
runner = ChefSpec::Runner.new do |node|
11+
node.override['cluster']['disable_services'] = DISABLE_SERVICE_NAME
12+
end
13+
runner.converge(described_recipe)
814
end
915

1016
it 'disables DLAMI multi eni helper' do
@@ -18,6 +24,15 @@
1824
is_expected.to stop_service('log4j-cve-2021-44228-hotpatch')
1925
is_expected.to mask_service('log4j-cve-2021-44228-hotpatch')
2026
end
27+
28+
DISABLE_SERVICE_NAME.split(" ").each do | service_name |
29+
it "disables #{service_name}" do
30+
is_expected.to disable_service(service_name)
31+
is_expected.to stop_service(service_name)
32+
is_expected.to mask_service(service_name)
33+
end
34+
end
35+
2136
end
2237
end
2338
end

0 commit comments

Comments
 (0)