-
Notifications
You must be signed in to change notification settings - Fork 104
/
compute_base_config.rb
126 lines (110 loc) · 3.43 KB
/
compute_base_config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# frozen_string_literal: true
#
# Cookbook Name:: aws-parallelcluster
# Recipe:: compute_base_config
#
# Copyright 2013-2015 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.
# Retrieve head node info
if node['cfncluster']['cfn_scheduler'] == 'slurm'
ruby_block "retrieve head_node ip" do
block do
head_node_private_ip, head_node_private_dns = hit_head_node_info
node.force_default['cfncluster']['cfn_master'] = head_node_private_dns
node.force_default['cfncluster']['cfn_master_private_ip'] = head_node_private_ip
end
retries 5
retry_delay 3
end
end
# Parse and get RAID shared directory info and turn into an array
raid_shared_dir = node['cfncluster']['cfn_raid_parameters'].split(',')[0]
if raid_shared_dir != "NONE"
# Path needs to be fully qualified, for example "shared/temp" becomes "/shared/temp"
raid_shared_dir = "/" + raid_shared_dir unless raid_shared_dir.start_with?("/")
# Created RAID shared mount point
directory raid_shared_dir do
mode '1777'
owner 'root'
group 'root'
action :create
end
# Mount RAID directory over NFS
mount raid_shared_dir do
device(lazy { "#{node['cfncluster']['cfn_master_private_ip']}:#{raid_shared_dir}" })
fstype 'nfs'
options 'hard,intr,noatime,_netdev'
action %i[mount enable]
retries 3
retry_delay 5
end
end
# Mount /home over NFS
mount '/home' do
device(lazy { "#{node['cfncluster']['cfn_master_private_ip']}:/home" })
fstype 'nfs'
options 'hard,intr,noatime,_netdev'
action %i[mount enable]
retries 3
retry_delay 5
end
# Mount /opt/intel over NFS
mount '/opt/intel' do
device(lazy { "#{node['cfncluster']['cfn_master_private_ip']}:/opt/intel" })
fstype 'nfs'
options 'hard,intr,noatime,_netdev'
action %i[mount enable]
retries 3
retry_delay 5
only_if { ::File.directory?("/opt/intel") }
end
# Configure Ganglia
include_recipe 'aws-parallelcluster::ganglia_config'
# Setup cluster user
user node['cfncluster']['cfn_cluster_user'] do
manage_home false
comment 'AWS ParallelCluster user'
home "/home/#{node['cfncluster']['cfn_cluster_user']}"
shell '/bin/bash'
end
# Parse shared directory info and turn into an array
shared_dir_array = node['cfncluster']['cfn_shared_dir'].split(',')
# Mount each volume with NFS
shared_dir_array.each do |dir|
dirname = dir.strip
unless dirname == "NONE"
dirname = "/" + dirname unless dirname.start_with?("/")
# Created shared mount point
directory dirname do
mode '1777'
owner 'root'
group 'root'
recursive true
action :create
end
# Mount shared volume over NFS
mount dirname do
device(lazy { "#{node['cfncluster']['cfn_master_private_ip']}:#{dirname}" })
fstype 'nfs'
options 'hard,intr,noatime,_netdev'
action %i[mount enable]
retries 3
retry_delay 5
end
end
end
# Install nodewatcher.cfg
template '/etc/nodewatcher.cfg' do
source 'nodewatcher.cfg.erb'
owner 'root'
group 'root'
mode '0644'
end