-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[develop] Share the munge key from the Parallel Cluster shared folder #2467
Changes from all commits
6b97f55
5277e96
c4f04f8
bc3e6f9
5d3515b
345f1e7
fd317a2
4ebfe64
440d8ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,5 +189,5 @@ suites: | |
scheduler: 'slurm' | ||
config: | ||
DevSettings: | ||
SlurmSettings: | ||
MungeKeySettings: | ||
MungeKeySecretArn: null |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,7 +78,7 @@ def setup_munge_head_node | |
# Generate munge key or get it's value from secrets manager | ||
munge_key_manager 'manage_munge_key' do | ||
munge_key_secret_arn lazy { | ||
node['cluster']['config'].dig(:DevSettings, :SlurmSettings, :MungeKeySecretArn) | ||
node['cluster']['config'].dig(:DevSettings, :MungeKeySettings, :MungeKeySecretArn) | ||
} | ||
end | ||
|
||
|
@@ -88,7 +88,7 @@ def setup_munge_head_node | |
|
||
def update_munge_head_node | ||
munge_key_manager 'update_munge_key' do | ||
munge_key_secret_arn lazy { node['cluster']['config'].dig(:DevSettings, :SlurmSettings, :MungeKeySecretArn) } | ||
munge_key_secret_arn lazy { node['cluster']['config'].dig(:DevSettings, :MungeKeySettings, :MungeKeySecretArn) } | ||
action :update_munge_key | ||
only_if { ::File.exist?(node['cluster']['previous_cluster_config_path']) && is_custom_munge_key_updated? } | ||
end | ||
|
@@ -97,38 +97,51 @@ def update_munge_head_node | |
share_munge_head_node | ||
end | ||
|
||
def share_munge_head_node | ||
# Share munge key | ||
def share_munge_key_to_dir(shared_dir) | ||
bash 'share_munge_key' do | ||
user 'root' | ||
group 'root' | ||
code <<-HEAD_SHARE_MUNGE_KEY | ||
code <<-SHARE_MUNGE_KEY | ||
set -e | ||
mkdir -p /home/#{node['cluster']['cluster_user']}/.munge | ||
mkdir -p #{shared_dir}/.munge | ||
# Copy key to shared dir | ||
cp /etc/munge/munge.key /home/#{node['cluster']['cluster_user']}/.munge/.munge.key | ||
HEAD_SHARE_MUNGE_KEY | ||
cp /etc/munge/munge.key #{shared_dir}/.munge/.munge.key | ||
chmod 0700 #{shared_dir}/.munge | ||
chmod 0600 #{shared_dir}/.munge/.munge.key | ||
SHARE_MUNGE_KEY | ||
end | ||
end | ||
|
||
def setup_munge_compute_node | ||
# Get munge key | ||
def share_munge_head_node | ||
share_munge_key_to_dir(node['cluster']['shared_dir']) | ||
share_munge_key_to_dir(node['cluster']['shared_dir_login']) | ||
end | ||
|
||
def setup_munge_key(shared_dir) | ||
bash 'get_munge_key' do | ||
user 'root' | ||
group 'root' | ||
code <<-COMPUTE_MUNGE_KEY | ||
code <<-MUNGE_KEY | ||
set -e | ||
# Copy munge key from shared dir | ||
cp /home/#{node['cluster']['cluster_user']}/.munge/.munge.key /etc/munge/munge.key | ||
cp #{shared_dir}/.munge/.munge.key /etc/munge/munge.key | ||
# Set ownership on the key | ||
chown #{node['cluster']['munge']['user']}:#{node['cluster']['munge']['group']} /etc/munge/munge.key | ||
# Enforce correct permission on the key | ||
chmod 0600 /etc/munge/munge.key | ||
COMPUTE_MUNGE_KEY | ||
MUNGE_KEY | ||
retries 5 | ||
retry_delay 10 | ||
end | ||
end | ||
|
||
def setup_munge_compute_node | ||
setup_munge_key(node['cluster']['shared_dir']) | ||
enable_munge_service | ||
end | ||
|
||
def setup_munge_login_node | ||
setup_munge_key(node['cluster']['shared_dir_login']) | ||
enable_munge_service | ||
end | ||
Comment on lines
+143
to
146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NitPick: this is trivial enough to be placed directly in the config_compute recipe. But I guess we need a more general refactoring later on (to move these helper functions inside the munge resource), so we can leave it this way for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense! Thanks Jacopo! |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
munge_user_dir = "/home/#{node['cluster']['cluster_user']}/.munge" | ||
directory munge_user_dir do | ||
mode '1777' | ||
end | ||
munge_dirs = %W(#{node['cluster']['shared_dir']}/.munge #{node['cluster']['shared_dir_login']}/.munge) | ||
|
||
munge_dirs.each do |munge_dir| | ||
directory munge_dir do | ||
mode '0700' | ||
end | ||
|
||
file "#{munge_user_dir}/.munge.key" do | ||
content 'munge-key' | ||
owner node['cluster']['munge']['user'] | ||
group node['cluster']['munge']['group'] | ||
file "#{munge_dir}/.munge.key" do | ||
content 'munge-key' | ||
jdeamicis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
owner node['cluster']['munge']['user'] | ||
group node['cluster']['munge']['group'] | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NitPick: this is trivial enough to be placed directly in the config_compute recipe. But I guess we need a more general refactoring later on (to move these helper functions inside the munge resource), so we can leave it this way for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Thanks Jacopo!