Skip to content

Commit 0b39579

Browse files
davpratgmarciani
authored andcommitted
Add install recipe for MySQL Repository
Signed-off-by: David Pratt <[email protected]>
1 parent 2bfce8a commit 0b39579

File tree

3 files changed

+116
-21
lines changed

3 files changed

+116
-21
lines changed

attributes/default.rb

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,40 @@
228228
)
229229

230230
# MySQL
231+
default['cluster']['mysql']['repository']['definition']['file-name'] = value_for_platform(
232+
'default' => "mysql80-community-release-el7-7.noarch.rpm",
233+
'ubuntu' => { 'default' => "mysql-apt-config_0.8.23-1_all.deb" }
234+
)
235+
236+
default['cluster']['mysql']['repository']['definition']['url'] = "https://dev.mysql.com/get/#{node['cluster']['mysql']['repository']['definition']['file-name']}"
237+
default['cluster']['mysql']['repository']['definition']['md5'] = value_for_platform(
238+
'default' => "659400f9842fffb8d64ae0b650f081b9",
239+
'ubuntu' => { 'default' => "c2b410031867dc7c966ca5b1aa0c72aa" }
240+
)
241+
242+
243+
default['cluster']['mysql']['package']['url'] = "https://#{node['cluster']['region']}-aws-parallelcluster.s3.#{node['cluster']['region']}.#{node['cluster']['aws_domain']}/archives"
244+
default['cluster']['mysql']['package']['root'] = "https://aws-parallelcluster-dev-commercial.s3.amazonaws.com/archives/mysql"
245+
default['cluster']['mysql']['package']['version'] = "8.0.31-1"
246+
default['cluster']['mysql']['package']['source-version'] = "8.0.31"
247+
if arm_instance?
248+
default['cluster']['mysql']['package']['platform'] = value_for_platform(
249+
'default' => "el/7/aarch64"
250+
)
251+
else
252+
default['cluster']['mysql']['package']['platform'] = value_for_platform(
253+
'default' => "el/7/x86_64",
254+
'ubuntu' => {
255+
'20.04' => "ubuntu/20.04/x86_64",
256+
'18.04' => "ubuntu/18.04/x86_64"
257+
}
258+
)
259+
end
260+
default['cluster']['mysql']['package']['file-name'] = "mysql-community-client-#{node['cluster']['mysql']['package']['version']}.tar.gz"
261+
default['cluster']['mysql']['package']['archive'] = "#{node['cluster']['mysql']['package']['root']}/#{node['cluster']['mysql']['package']['platform']}/#{node['cluster']['mysql']['package']['file-name']}"
262+
default['cluster']['mysql']['package']['source'] = "#{node['cluster']['mysql']['package']['root']}/source/mysql-#{node['cluster']['mysql']['package']['source-version']}.tar.gz"
263+
264+
# MySQL Validation
231265
if arm_instance?
232266
default['cluster']['mysql']['repository']['packages'] = value_for_platform(
233267
'default' => %w(mysql-community-devel mysql-community-libs mysql-community-common mysql-community-client-plugins),
@@ -252,27 +286,6 @@
252286
end
253287

254288

255-
default['cluster']['mysql']['package']['url'] = "https://#{node['cluster']['region']}-aws-parallelcluster.s3.#{node['cluster']['region']}.#{node['cluster']['aws_domain']}/archives"
256-
default['cluster']['mysql']['package']['root'] = "https://aws-parallelcluster-dev-commercial.s3.amazonaws.com/archives/mysql"
257-
default['cluster']['mysql']['package']['version'] = "8.0.31-1"
258-
default['cluster']['mysql']['package']['source-version'] = "8.0.31"
259-
if arm_instance?
260-
default['cluster']['mysql']['package']['platform'] = value_for_platform(
261-
'default' => "el/7/aarch64"
262-
)
263-
else
264-
default['cluster']['mysql']['package']['platform'] = value_for_platform(
265-
'default' => "el/7/x86_64",
266-
'ubuntu' => {
267-
'20.04' => "ubuntu/20.04/x86_64",
268-
'18.04' => "ubuntu/18.04/x86_64"
269-
}
270-
)
271-
end
272-
default['cluster']['mysql']['package']['file-name'] = "mysql-community-client-#{node['cluster']['mysql']['package']['version']}.tar.gz"
273-
default['cluster']['mysql']['package']['archive'] = "#{node['cluster']['mysql']['package']['root']}/#{node['cluster']['mysql']['package']['platform']}/#{node['cluster']['mysql']['package']['file-name']}"
274-
default['cluster']['mysql']['package']['source'] = "#{node['cluster']['mysql']['package']['root']}/source/mysql-#{node['cluster']['mysql']['package']['source-version']}.tar.gz"
275-
276289

277290
# EFA
278291
default['cluster']['efa']['installer_version'] = '1.18.0'
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Cookbook:: aws-parallelcluster
5+
# Recipe:: mysql
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+
def install_repository_configuration_package(repository_name, definition_source, local_file, md5_hash)
19+
remote_file local_file do
20+
source definition_source
21+
mode '0644'
22+
retries 3
23+
retry_delay 5
24+
not_if { ::File.exist?(local_file) }
25+
end
26+
27+
ruby_block "Validate Repository Definition Checksum" do
28+
block do
29+
require 'digest'
30+
checksum = Digest::MD5.file(local_file).hexdigest
31+
32+
if checksum != md5_hash
33+
raise "Downloaded file #{local_file} checksum #{checksum} does not match expected checksum #{md5_hash}"
34+
end
35+
end
36+
end
37+
38+
if platform?('ubuntu')
39+
# dpkg_package is used here because 'package' seems to default to using apt_package
40+
# which fails on the MySQL package.
41+
dpkg_package repository_name do
42+
source local_file
43+
end
44+
45+
apt_update 'update' do
46+
action :update
47+
retries 3
48+
retry_delay 5
49+
end
50+
else
51+
package repository_name do
52+
source local_file
53+
end
54+
end
55+
end
56+
57+
unless platform?('ubuntu') && arm_instance?
58+
install_repository_configuration_package(
59+
"MySQL Repository",
60+
node['cluster']['mysql']['repository']['definition']['url'],
61+
"/tmp/#{node['cluster']['mysql']['repository']['definition']['file-name']}",
62+
node['cluster']['mysql']['repository']['definition']['md5']
63+
)
64+
end

recipes/post_install.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Cookbook:: aws-parallelcluster
5+
# Recipe:: default
6+
#
7+
# Copyright:: 2013-2021 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+
include_recipe 'aws-parallelcluster-install::install_mysql_repository'

0 commit comments

Comments
 (0)