forked from aws/aws-parallelcluster-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kitchen.ec2.yml
207 lines (198 loc) · 7.8 KB
/
kitchen.ec2.yml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<%
pcluster_version = ENV['KITCHEN_PCLUSTER_VERSION'] || '3.7.0'
pcluster_prefix = "aws-parallelcluster-#{pcluster_version}"
%>
---
driver:
name: ec2
aws_ssh_key_id: <%= ENV['KITCHEN_KEY_NAME'] %>
<% if ENV['KITCHEN_SECURITY_GROUP_ID'] %>
security_group_ids: [ "<%= ENV['KITCHEN_SECURITY_GROUP_ID'] %>" ]
<% else %>
security_group_filter:
tag: 'Kitchen'
value: 'true'
<% end %>
region: <%= ENV['KITCHEN_AWS_REGION'] %>
availability_zone: <%= ENV['KITCHEN_AVAILABILITY_ZONE'] %>
subnet_id: <%= ENV['KITCHEN_SUBNET_ID'] %>
# Disable IMDS v1
metadata_options:
http_tokens: 'required'
http_put_response_hop_limit: 1
instance_metadata_tags: 'enabled'
iam_profile_name: <%= ENV['KITCHEN_IAM_PROFILE'] %>
instance_type: <%= ENV['KITCHEN_INSTANCE_TYPE'] || 'c5n.xlarge' %>
associate_public_ip: true
user_data: <%= ENV['KITCHEN_USER_DATA_SCRIPT'] %>
tags:
created-by: test-kitchen
Name: test-kitchen-parallelcluster
lifecycle:
post_verify:
- local: |
[[ ${KITCHEN_SAVE_IMAGE} == 'true' ]] || exit 0
echo "*** Retrieve EC2 instance id using key ${KITCHEN_SSH_KEY_PATH}"
case $KITCHEN_PLATFORM_NAME in
alinux*|redhat* ) export KITCHEN_EC2_USER='ec2-user';;
centos* ) export KITCHEN_EC2_USER='centos';;
ubuntu* ) export KITCHEN_EC2_USER='ubuntu';;
esac
KITCHEN_EC2_INSTANCE_ID=$(ssh -o StrictHostKeyChecking=no -i "${KITCHEN_SSH_KEY_PATH}" \
"${KITCHEN_EC2_USER}@${KITCHEN_INSTANCE_HOSTNAME}" '
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/instance-id
')
echo "EC2 instance id: ${KITCHEN_EC2_INSTANCE_ID}"
aws ec2 create-image --instance-id ${KITCHEN_EC2_INSTANCE_ID} --name pcluster-${KITCHEN_PHASE}/${KITCHEN_INSTANCE_NAME}
transport:
<% if ENV['KITCHEN_SSH_KEY_PATH'] %>
ssh_key: <%= ENV['KITCHEN_SSH_KEY_PATH'] %>
<% end %>
compression: true
name: speedy_ssh
provisioner:
product_name: cinc
product_version: 17.2.29
install_strategy: once
chef_omnibus_url: https://omnitruck.cinc.sh/install.sh
chef_omnibus_root: /opt/cinc
retry_on_exit_code:
- 35 # 35 is the exit code signaling that the node is rebooting
max_retries: 1
wait_for_retry: 120
client_rb:
exit_status: :enabled # Opt-in to the standardized exit codes
client_fork: false # Forked instances don't return the real exit code
log_level: info
platforms:
- name: alinux2
driver_plugin: ec2
driver:
<% if ENV['KITCHEN_ALINUX2_AMI'] %>
# Use the Amazon Linux 2 AMI most similar to the base AMI used to build the ParallelCluster image
image_id: <%= ENV['KITCHEN_ALINUX2_AMI'] %>
<% else %>
image_search:
name: <% if ENV['KITCHEN_PHASE']=='install' %>amzn2-ami-kernel-5.10-hvm*<% else %><%= pcluster_prefix %>-amzn2-hvm-*<% end %>
architecture: <%= ENV['KITCHEN_ARCHITECTURE'] %>
<% end %>
block_device_mappings:
- device_name: /dev/xvda
ebs:
volume_size: <% if (ENV['KITCHEN_VOLUME_SIZE'] || '') == '' %> 35 <% else %> <%= ENV['KITCHEN_VOLUME_SIZE'] %> <% end %>
volume_type: gp2
delete_on_termination: true
<% %w(a b c d e f g h i j k l m n o p q r s t u v w x).each_with_index do | c, i | %>
- device_name: /dev/xvdb<%= c %>
virtual_name: ephemeral<%= i %>
<% end %>
transport:
username: ec2-user
attributes:
cluster:
base_os: alinux2
- name: rhel8
driver_plugin: ec2
driver:
<% if ENV['KITCHEN_RHEL8_AMI'] %>
# Use the RedHat 8 AMI most similar to the base AMI used to build the ParallelCluster image
image_id: <%= ENV['KITCHEN_RHEL8_AMI'] %>
<% else %>
image_search:
name: <% if ENV['KITCHEN_PHASE']=='install' %>RHEL-8.7.*_HVM*<% else %><%= pcluster_prefix %>-rhel8-hvm-*<% end %>
architecture: <%= ENV['KITCHEN_ARCHITECTURE'] %>
<% end %>
block_device_mappings:
- device_name: /dev/sda1
ebs:
volume_size: <% if (ENV['KITCHEN_VOLUME_SIZE'] || '') == '' %> 35 <% else %> <%= ENV['KITCHEN_VOLUME_SIZE'] %> <% end %>
volume_type: gp2
delete_on_termination: true
<% %w(a b c d e f g h i j k l m n o p q r s t u v w x).each_with_index do | c, i | %>
- device_name: /dev/xvdb<%= c %>
virtual_name: ephemeral<%= i %>
<% end %>
transport:
username: ec2-user
attributes:
cluster:
base_os: rhel8
- name: centos7
driver_plugin: ec2
driver:
<% if ENV['KITCHEN_CENTOS7_AMI'] %>
# Use the CentOS 7 AMI most similar to the base AMI used to build the ParallelCluster image
image_id: <%= ENV['KITCHEN_CENTOS7_AMI'] %>
<% else %>
image_search:
name: <% if ENV['KITCHEN_PHASE']=='install' %>CentOS Linux 7 *- 2211<% else %><%= pcluster_prefix %>-centos7-hvm-*<% end %>
architecture: <%= ENV['KITCHEN_ARCHITECTURE'] %>
<% end %>
block_device_mappings:
- device_name: /dev/sda1
ebs:
volume_size: <% if (ENV['KITCHEN_VOLUME_SIZE'] || '') == '' %> 35 <% else %> <%= ENV['KITCHEN_VOLUME_SIZE'] %> <% end %>
volume_type: gp2
delete_on_termination: true
<% %w(a b c d e f g h i j k l m n o p q r s t u v w x).each_with_index do | c, i | %>
- device_name: /dev/xvdb<%= c %>
virtual_name: ephemeral<%= i %>
<% end %>
transport:
username: centos
attributes:
cluster:
base_os: centos7
- name: ubuntu2004
driver_plugin: ec2
driver:
<% if ENV['KITCHEN_UBUNTU2004_AMI'] %>
# Use the Ubuntu 20 AMI most similar to the base AMI used to build the ParallelCluster image
image_id: <%= ENV['KITCHEN_UBUNTU2004_AMI'] %>
<% else %>
image_search:
name: <% if ENV['KITCHEN_PHASE']=='install' %>ubuntu/images/hvm-ssd/ubuntu-focal-20.04-<% if ENV['KITCHEN_ARCHITECTURE'] == 'x86_64' %>amd64<% else %>arm64<% end %>-server-20230112<% else %><%= pcluster_prefix %>-ubuntu-2004-lts-hvm-*<% end %>
architecture: <%= ENV['KITCHEN_ARCHITECTURE'] %>
<% end %>
block_device_mappings:
- device_name: /dev/sda1
ebs:
volume_size: <% if (ENV['KITCHEN_VOLUME_SIZE'] || '') == '' %> 35 <% else %> <%= ENV['KITCHEN_VOLUME_SIZE'] %> <% end %>
volume_type: gp2
delete_on_termination: true
<% %w(a b c d e f g h i j k l m n o p q r s t u v w x).each_with_index do | c, i | %>
- device_name: /dev/xvdb<%= c %>
virtual_name: ephemeral<%= i %>
<% end %>
transport:
username: ubuntu
attributes:
cluster:
base_os: ubuntu2004
- name: ubuntu2204
driver_plugin: ec2
driver:
<% if ENV['KITCHEN_UBUNTU2204_AMI'] %>
# Use the Ubuntu 22 AMI most similar to the base AMI used to build the ParallelCluster image
image_id: <%= ENV['KITCHEN_UBUNTU2204_AMI'] %>
<% else %>
image_search:
name: ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-<% if ENV['KITCHEN_ARCHITECTURE'] == 'x86_64' %>amd64<% else %>arm64<% end %>-server-20230106
architecture: <%= ENV['KITCHEN_ARCHITECTURE'] %>
<% end %>
block_device_mappings:
- device_name: /dev/sda1
ebs:
volume_size: <% if (ENV['KITCHEN_VOLUME_SIZE'] || '') == '' %> 35 <% else %> <%= ENV['KITCHEN_VOLUME_SIZE'] %> <% end %>
volume_type: gp2
delete_on_termination: true
<% %w(a b c d e f g h i j k l m n o p q r s t u v w x).each_with_index do | c, i | %>
- device_name: /dev/xvdb<%= c %>
virtual_name: ephemeral<%= i %>
<% end %>
transport:
username: ubuntu
attributes:
cluster:
base_os: ubuntu2204