Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit dad0d84

Browse files
authored
In CentOS wget does not exist by default. And when it is not there, the or logic does not work as wanted. (#309)
Bugfix: module init-snippet-attach-ebs-volume In CentOS `wget` does not exist by default. And when it is not there, the or logic does not work as wanted.
1 parent b4feb7f commit dad0d84

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,33 @@
99

1010
### Examples
1111

12+
# v0.9.14
13+
14+
### Summary
15+
16+
New modules and function extendings.
17+
18+
### Modules
19+
20+
* dlm-lifecycle-policy: Merge dlm-lifecycle-iam-role.
21+
22+
* init-snippet-install-docker-yum: CentOS script to install docker/docker-compose.
23+
24+
* init-snippet-attach-ebs-volume: Working on CentOS now. Generates required device name now despite Linux differences.
25+
26+
* single-node-asg: Output the attached EBS Name tag for DLM to match.
27+
28+
* rds: RDS database.
29+
30+
* s3-remote-state: fix for #286.
31+
32+
* asg: add protect_from_scale_in and suspended_processes attrs.
33+
34+
### Examples
35+
36+
* No changes
37+
38+
1239
# v0.9.13
1340

1441
### Summary

modules/init-snippet-attach-ebs-volume/snippet.tpl

+25-16
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,33 @@
22
${init_prefix}
33
export AWS_DEFAULT_REGION=${region}
44
VOLUME_ID=${volume_id}
5-
INSTANCE_ID="$(wget -O- http://169.254.169.254/latest/meta-data/instance-id || curl http://169.254.169.254/latest/meta-data/instance-id)"
6-
echo "${log_prefix} will attach $${VOLUME_ID} via the AWS API in ${region}"
7-
while ! aws ec2 attach-volume \
5+
if which wget; then
6+
INSTANCE_ID="$(wget -O- http://169.254.169.254/latest/meta-data/instance-id)"
7+
elif which curl; then
8+
INSTANCE_ID="$(curl http://169.254.169.254/latest/meta-data/instance-id)"
9+
fi
10+
11+
if [ "x$${INSTANCE_ID}" == "x" ]; then
12+
echo 'OS not functioning'
13+
else
14+
echo "${log_prefix} will attach $${VOLUME_ID} via the AWS API in ${region}"
15+
while ! aws ec2 attach-volume \
816
--volume-id "$${VOLUME_ID}" \
917
--instance-id "$${INSTANCE_ID}" \
1018
--device '${device_path}'; do
11-
echo "Attaching command failed to run. Retrying."
12-
sleep '${wait_interval}'
13-
done
14-
echo "${log_prefix} $${VOLUME_ID} attached."
15-
16-
vol_id="$(echo "$${VOLUME_ID}" | tr -d '-')"
17-
while [ ! -e /dev/disk/by-id/*-Amazon_Elastic_Block_Store_$${vol_id} ]; do
18-
sleep '${wait_interval}'
19-
done
20-
21-
dev_id="$(ls /dev/disk/by-id/*-Amazon_Elastic_Block_Store_$${vol_id} | head -1)"
22-
dev_name="/dev/$(readlink "$${dev_id}" | tr / '\n' | tail -1)"
23-
[ "$${dev_name}" == "${device_path}" ] || ln -s "$${dev_name}" "${device_path}"
19+
echo "Attaching command failed to run. Retrying."
20+
sleep '${wait_interval}'
21+
done
22+
echo "${log_prefix} $${VOLUME_ID} attached."
23+
24+
vol_id="$(echo "$${VOLUME_ID}" | tr -d '-')"
25+
while [ ! -e /dev/disk/by-id/*-Amazon_Elastic_Block_Store_$${vol_id} ]; do
26+
sleep '${wait_interval}'
27+
done
28+
29+
dev_id="$(ls /dev/disk/by-id/*-Amazon_Elastic_Block_Store_$${vol_id} | head -1)"
30+
dev_name="/dev/$(readlink "$${dev_id}" | tr / '\n' | tail -1)"
31+
[ "$${dev_name}" == "${device_path}" ] || ln -s "$${dev_name}" "${device_path}"
32+
fi
2433

2534
${init_suffix}

0 commit comments

Comments
 (0)