Skip to content

Commit 44afbc0

Browse files
hanwen-clusterhanwen-pcluste
authored andcommitted
Install EFS-utils on Amazon Linux 2 AMI
The installation procedure follows the guide https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html#installing-other-distro See section "To build and install amazon-efs-utils as an RPM package (for distributions other than OpenSUSE or SLES)" Signed-off-by: Hanwen <[email protected]>
1 parent 3430abb commit 44afbc0

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

attributes/default.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@
266266
default['cluster']['efa']['installer_url'] = "https://efa-installer.amazonaws.com/aws-efa-installer-#{node['cluster']['efa']['installer_version']}.tar.gz"
267267
default['cluster']['efa']['unsupported_aarch64_oses'] = %w(centos7)
268268

269+
# EFS Utils
270+
default['cluster']['efs_utils']['version'] = '1.34.1'
271+
default['cluster']['efs_utils']['url'] = "https://github.com/aws/efs-utils/archive/v#{node['cluster']['efs_utils']['version']}.tar.gz"
272+
default['cluster']['efs_utils']['sha256'] = '69d0d8effca3b58ccaf4b814960ec1d16263807e508b908975c2627988c7eb6c'
273+
269274
# NICE DCV
270275
default['cluster']['dcv_port'] = 8443
271276
default['cluster']['dcv']['installed'] = 'yes'

cookbooks/aws-parallelcluster-install/libraries/helpers.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,15 @@ def disable_service(service, platform_families = node['platform_family'], operat
2222
end
2323
end
2424
end
25+
26+
def get_package_version(package_name)
27+
cmd = value_for_platform(
28+
'default' => "rpm -qi #{package_name} | grep Version | awk '{print $3}'",
29+
'ubuntu' => { "default" => "dpkg-query --showformat='${Version}' --show #{package_name} | awk -F- '{print $1}'" })
30+
package_version_cmd = Mixlib::ShellOut.new(cmd)
31+
version = package_version_cmd.run_command.stdout.strip
32+
if version.empty?
33+
Chef::Log.info("#{package_name} not found when trying to get the version.")
34+
end
35+
version
36+
end

cookbooks/aws-parallelcluster-install/recipes/base.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@
218218
# Install FSx options
219219
include_recipe "aws-parallelcluster-install::lustre"
220220

221+
# Install EFS Utils
222+
include_recipe "aws-parallelcluster-install::efs"
223+
221224
# Install the AWS cloudwatch agent
222225
include_recipe "aws-parallelcluster-install::cloudwatch_agent"
223226

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Cookbook:: aws-parallelcluster
5+
# Recipe:: efs
6+
#
7+
# Copyright:: 2013-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the
10+
# License. A copy of the License is located at
11+
#
12+
# http://aws.amazon.com/apache2.0/
13+
#
14+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
15+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
package_name = "amazon-efs-utils"
19+
efs_utils_tarball = "#{node['cluster']['sources_dir']}/efs-utils-#{node['cluster']['efs_utils']['version']}.tar.gz"
20+
return unless platform?('amazon')
21+
22+
# Do not install efs-utils if a same or newer version is already installed.
23+
return if Gem::Version.new(get_package_version(package_name)) >= Gem::Version.new(node['cluster']['efs_utils']['version'])
24+
25+
# Get EFS Utils tarball
26+
remote_file efs_utils_tarball do
27+
source node['cluster']['efs_utils']['url']
28+
mode '0644'
29+
retries 3
30+
retry_delay 5
31+
not_if { ::File.exist?(efs_utils_tarball) }
32+
end
33+
34+
# Verify tarball
35+
ruby_block "verify EFS Utils checksum" do
36+
block do
37+
require 'digest'
38+
checksum = Digest::SHA256.file(efs_utils_tarball).hexdigest
39+
raise "Downloaded EFS Utils package checksum #{checksum} does not match expected checksum #{node['cluster']['efs_utils']['sha256']}" if checksum != node['cluster']['efs_utils']['sha256']
40+
end
41+
end
42+
43+
# Install EFS Utils
44+
bash "install efs utils" do
45+
cwd node['cluster']['sources_dir']
46+
code <<-EFSUTILSINSTALL
47+
set -e
48+
tar xf #{efs_utils_tarball}
49+
cd efs-utils-#{node['cluster']['efs_utils']['version']}
50+
make rpm
51+
yum -y install ./build/#{package_name}*rpm
52+
EFSUTILSINSTALL
53+
end

0 commit comments

Comments
 (0)