Skip to content

Commit b382f0d

Browse files
Rexrexcsn
authored andcommitted
Refactoring Munge setup
* Refactor process to setup munge key Signed-off-by: Rex <[email protected]>
1 parent 836b6bf commit b382f0d

File tree

10 files changed

+54
-31
lines changed

10 files changed

+54
-31
lines changed

attributes/default.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@
108108
# Munge
109109
default['cfncluster']['munge']['munge_version'] = '0.5.14'
110110
default['cfncluster']['munge']['munge_url'] = "https://github.com/dun/munge/archive/munge-#{node['cfncluster']['munge']['munge_version']}.tar.gz"
111-
# Munge key
112-
default['cfncluster']['munge']['munge_key'] = 'YflQEFLjoxsmEK5vQyKklkLKJ#LkjLKDJF@*(#)ajLKQ@hLKN#()FSU(#@KLJH$@HKSASG)*DUJJDksdN'
113111

114112
# Ganglia
115113
default['cfncluster']['ganglia_enabled'] = 'no'

libraries/helpers.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,46 @@ def overwrite_nfs_template?
432432
node['platform'] == 'centos' && node['platform_version'].to_i == 8
433433
].any?
434434
end
435+
436+
def enable_munge_service
437+
service "munge" do
438+
supports restart: true
439+
action %i[enable start]
440+
end
441+
end
442+
443+
def setup_munge_head_node
444+
# Generate munge key
445+
bash 'generate_munge_key' do
446+
user 'munge'
447+
group 'munge'
448+
cwd '/tmp'
449+
code <<-HEAD_MUNGE_KEY
450+
set -e
451+
# Generates munge key in /etc/munge/munge.key
452+
/usr/sbin/mungekey --verbose
453+
# Enforce correct permission on the key
454+
chmod 0600 /etc/munge/munge.key
455+
# Copy key to shared dir
456+
cp -p /etc/munge/munge.key /home/munge/.munge.key
457+
HEAD_MUNGE_KEY
458+
end
459+
460+
enable_munge_service()
461+
end
462+
463+
def setup_munge_compute_node
464+
# Get munge key
465+
bash 'get_munge_key' do
466+
user 'munge'
467+
group 'munge'
468+
cwd '/tmp'
469+
code <<-COMPUTE_MUNGE_KEY
470+
set -e
471+
# Copy munge key from shared dir
472+
cp -p /home/munge/.munge.key /etc/munge/munge.key
473+
COMPUTE_MUNGE_KEY
474+
end
475+
476+
enable_munge_service()
477+
end

recipes/compute_slurm_config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
setup_munge_compute_node()
19+
1820
# Create directory configured as SlurmdSpoolDir
1921
directory '/var/spool/slurmd' do
2022
user 'slurm'

recipes/compute_torque_config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
setup_munge_compute_node()
19+
1820
# pbs_mom config
1921
template '/var/spool/torque/mom_priv/config' do
2022
source 'torque.config.erb'

recipes/head_node_slurm_config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
setup_munge_head_node()
19+
1820
# Export /opt/slurm
1921
nfs_export "/opt/slurm" do
2022
network node['cfncluster']['ec2-metadata']['vpc-ipv4-cidr-blocks']

recipes/head_node_torque_config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18+
setup_munge_head_node()
19+
1820
# Modified torque.setup
1921
template 'torque.setup' do
2022
source 'torque.setup.erb'

recipes/munge_install.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,11 @@
6767

6868
# Make sure the munge user exists
6969
user 'munge' do
70-
manage_home false
70+
manage_home true
7171
comment 'munge user'
72+
home "/home/munge"
7273
system true
73-
shell '/sbin/nologin'
74+
shell '/usr/sbin/nologin'
7475
end
7576

7677
# Create required directories for munge

recipes/slurm_config.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@
1818
include_recipe 'aws-parallelcluster::base_config'
1919
include_recipe 'aws-parallelcluster::slurm_install'
2020

21-
# Create the munge key from template
22-
template "/etc/munge/munge.key" do
23-
source "munge.key.erb"
24-
owner "munge"
25-
mode "0600"
26-
end
27-
28-
# Enable munge service
29-
service "munge" do
30-
supports restart: true
31-
action %i[enable start]
32-
end
33-
3421
cookbook_file '/etc/init.d/slurm' do
3522
source 'slurm-init'
3623
owner 'root'

recipes/torque_config.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@
5454
action %i[enable start]
5555
end
5656

57-
# Create the munge key from template
58-
template "/etc/munge/munge.key" do
59-
source "munge.key.erb"
60-
owner "munge"
61-
mode "0600"
62-
end
63-
64-
# Enable munge service
65-
service "munge" do
66-
supports restart: true
67-
action %i[enable start]
68-
end
69-
7057
cookbook_file "/etc/profile.d/torque.sh" do
7158
source 'torque.sh'
7259
owner 'root'

templates/default/munge.key.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)