Skip to content

Commit d85a09c

Browse files
Stop the sshd service and close connections before moving the default user home (#2652)
1 parent c21eec7 commit d85a09c

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This file is used to list changes made in each version of the AWS ParallelCluste
1010
- Add support for RHEL9.
1111
- Add support for Rocky Linux 9 as `CustomAmi` created through `build-image` process. No public official ParallelCluster Rocky9 Linux AMI is made available at this time.
1212
- Add the configuration parameter `DeploymentSettings/DefaultUserHome` to allow users to move the default user's home directory to `/local/home` instead of `/home` (default).
13+
- SSH connections will be closed and rejected while the user's home directory is being moved during the bootstrapping process.
1314
- Add possibility to choose between Open and Closed Source Nvidia Drivers when building an AMI, through the ```['cluster']['nvidia']['kernel_open']``` cookbook node attribute.
1415

1516
**CHANGES**

cookbooks/aws-parallelcluster-environment/recipes/init/config_default_user_home.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@
1414

1515
return if node['cluster']['default_user_home'] == 'shared'
1616

17+
# Stop sshd and close all connections
18+
service 'sshd' do
19+
action :stop
20+
sensitive true
21+
end
22+
bash "Close ssh connections to perform a default user move" do
23+
user 'root'
24+
group 'root'
25+
returns [0, 1]
26+
code <<-EOH
27+
pkill --signal HUP sshd
28+
EOH
29+
end
30+
1731
# Backup the cluster user's default home directory
1832
bash "Backup #{node['cluster']['cluster_user_home']}" do
1933
user 'root'
@@ -46,3 +60,9 @@
4660
end
4761

4862
node.override['cluster']['cluster_user_home'] = node['cluster']['cluster_user_local_home']
63+
64+
# Start the sshd service again once the move is complete
65+
service 'sshd' do
66+
action :start
67+
sensitive true
68+
end

cookbooks/aws-parallelcluster-environment/spec/unit/recipes/config_default_user_home_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
cached(:node) { chef_run.node }
1616

1717
it 'runs the recipe' do
18+
is_expected.to stop_service("sshd")
19+
is_expected.to run_bash("Close ssh connections to perform a default user move")
1820
is_expected.to run_bash("Backup /home/user")
1921
is_expected.to run_bash("Move /home/user")
2022
expect(chef_run.node['cluster']['cluster_user_home']).to eq('/local/home/user')
23+
is_expected.to start_service("sshd")
2124
end
2225
end
2326
context 'when shared' do

0 commit comments

Comments
 (0)