-
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] Setup custom munge key #2443
Changes from 6 commits
47743f7
cbb3fbd
b8f5cfa
d2eb7a1
dcc5deb
76ef5b6
3595f63
ad81ea2
f5b51a1
a07c220
49dfda0
b2c1bb9
9e19ef0
5ee2022
7cff2cc
5626997
c5cbf8d
dc5bb79
334920d
2ce20d7
dc8dc8f
d88429b
6f71cbe
e7eeffa
59be5b5
e0e6f23
45224cd
9af2561
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Cookbook:: aws-parallelcluster-slurm | ||
# Recipe:: config_head_node | ||
# | ||
# Copyright:: 2013-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the | ||
# License. A copy of the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
resource_name :munge_key_manager | ||
provides :munge_key_manager | ||
unified_mode true | ||
|
||
property :munge_key_secret_arn, String | ||
|
||
default_action :manage | ||
|
||
action :manage do | ||
if new_resource.munge_key_secret_arn | ||
# This block will fetch the munge key from Secrets Manager | ||
bash 'fetch_and_decode_munge_key' do | ||
user 'root' | ||
group 'root' | ||
cwd '/tmp' | ||
code <<-FETCH_AND_DECODE | ||
# Get encoded munge key from secrets manager and decode it | ||
encoded_key=$(aws secretsmanager get-secret-value --secret-id #{new_resource.munge_key_secret_arn} --query 'SecretString' --output text) | ||
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. What if there's an error fetching the secret? This will not return the value. 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. Yes, done! |
||
echo $encoded_key | base64 -d > /etc/munge/munge.key | ||
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. Same here, what if base64 decoding fails? We need to add the base64 decoded key to 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. Done! |
||
# 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 | ||
FETCH_AND_DECODE | ||
end | ||
else | ||
# This block will generate a munge key if it doesn't exist | ||
bash 'generate_munge_key' do | ||
not_if { ::File.exist?('/etc/munge/munge.key') } | ||
user node['cluster']['munge']['user'] | ||
group node['cluster']['munge']['group'] | ||
cwd '/tmp' | ||
code <<-GENERATE_KEY | ||
set -e | ||
/usr/sbin/mungekey --verbose | ||
chmod 0600 /etc/munge/munge.key | ||
GENERATE_KEY | ||
end | ||
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.
Can we use a more descriptive action e.g.
:setup_munge_key
?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.
Sure!