Skip to content

Commit 89e4c46

Browse files
himani2411Himani Anil Deshpande
andauthored
Use disable_services.rb recipe to disable dynamic services we want using DevSettings (#2883)
Co-authored-by: Himani Anil Deshpande <himanidp@amazon.com>
1 parent a8d6227 commit 89e4c46

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This file is used to list changes made in each version of the AWS ParallelCluste
77
------
88
**ENHANCEMENTS**
99
- Add support for Ubuntu24.
10+
- Disable unused services like cups and wpa_supplicant from Official ParallelCluster AMIs to improve security.
1011

1112
**CHANGES**
1213
- On Ubuntu 22.04, install the Nvidia driver with the same compiler version used to compile the kernel.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@
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

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
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
68
cached(:chef_run) do
7-
runner(platform: platform, version: version).converge(described_recipe)
9+
runner = ChefSpec::Runner.new do |node|
10+
node.override['cluster']['disable_services'] = DISABLE_SERVICE_NAME
11+
end
12+
runner.converge(described_recipe)
813
end
914

1015
it 'disables DLAMI multi eni helper' do
@@ -18,6 +23,14 @@
1823
is_expected.to stop_service('log4j-cve-2021-44228-hotpatch')
1924
is_expected.to mask_service('log4j-cve-2021-44228-hotpatch')
2025
end
26+
27+
DISABLE_SERVICE_NAME.split().each do |service_name|
28+
it "disables #{service_name}" do
29+
is_expected.to disable_service(service_name)
30+
is_expected.to stop_service(service_name)
31+
is_expected.to mask_service(service_name)
32+
end
33+
end
2134
end
2235
end
2336
end

0 commit comments

Comments
 (0)