Skip to content

Commit 998ac18

Browse files
committed
Merge pull request #8 from awslabs/develop
Pulling v0.0.9
2 parents 00b537a + 9b5df02 commit 998ac18

File tree

9 files changed

+254
-179
lines changed

9 files changed

+254
-179
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
CHANGELOG
33
=========
44

5+
0.0.9
6+
=====
7+
8+
* feature:``cfncluster``: Added s3_read_resource and s3_read_write_resource options to cluster config
9+
* feature:``cfncluster``: cfncluster is now available in all regions
10+
* updates:``ami``: Pulled latest CentOS errata
11+
* feature:``cfncluster``: Added ephemeral_dir option to cluster config
12+
513
0.0.8
614
=====
715

amis.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
us-west-2 ami-cfbbc4ff
2-
us-east-1 ami-705d9918
3-
eu-west-1 ami-d15892a6
4-
ap-northeast-1 ami-6d64306c
1+
us-west-2 ami-750f7645
2+
eu-west-1 ami-7df5220a
3+
sa-east-1 ami-7753fd6a
4+
us-east-1 ami-0c458764
5+
ap-northeast-1 ami-4f38684e
6+
us-west-1 ami-1b8c8c5e
7+
ap-southeast-1 ami-da4e1788
8+
ap-southeast-2 ami-e5a9cedf

bootstrap/src/scripts/boot_as_compute

Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -13,79 +13,20 @@
1313

1414
set -x
1515

16+
# Source config
1617
. /opt/cfncluster/cfnconfig
1718

18-
function error_exit () {
19-
script=`basename $0`
20-
echo "cfncluster: $script - $1"
21-
logger -t cfncluster "$script - $1"
22-
exit 1
23-
}
19+
# Source functions
20+
. /opt/cfncluster/scripts/functions.shlib
2421

2522
# Run preinstall script if defined
26-
RC=0
27-
if [ "${cfn_preinstall}" != "NONE" ]; then
28-
tmpfile=$(mktemp)
29-
wget -qO- ${cfn_preinstall} > $tmpfile || RC=1
30-
if [ "${cfn_preinstall_args}" != "NONE" ]; then
31-
args=${cfn_preinstall_args}
32-
fi
33-
/bin/sh $tmpfile $args || RC=1
34-
/bin/rm $tmpfile
35-
fi
36-
if [ $RC -ne 0 ]; then
37-
error_exit "Failed to run boot_as_compute preinstall"
38-
fi
23+
run_preinstall
3924

4025
## Non-scheduler specific functions
4126
##
4227

43-
# LVM, format, mount /ephemeral
44-
RC=0
45-
mkdir -p /scratch
46-
chmod 1777 /scratch
47-
MAPPING=$(/usr/bin/ec2-metadata -b | grep ephemeral | awk '{print $2}' | sed 's/sd/xvd/')
48-
for m in $MAPPING; do
49-
stat -t /dev/${m} >/dev/null 2>&1
50-
check=$?
51-
if [ ${check} -eq 0 ]; then
52-
DEVS="${m} $DEVS"
53-
fi
54-
done
55-
NUM_DEVS=0
56-
for d in $DEVS; do
57-
d=/dev/${d}
58-
dd if=/dev/zero of=${d} bs=32k count=1
59-
parted -s ${d} mklabel msdos
60-
parted -s ${d}
61-
parted -s -a optimal ${d} mkpart primary 1MB 100%
62-
parted -s ${d} set 1 lvm on
63-
let NUM_DEVS++
64-
PARTITIONS="${d}1 $PARTITIONS"
65-
done
66-
# sleep 10 seconds to let partitions settle (bug?)
67-
sleep 10
68-
69-
# Setup LVM
70-
pvcreate $PARTITIONS
71-
vgcreate vg.01 $PARTITIONS
72-
lvcreate -i $NUM_DEVS -I 64 -l 100%FREE -n lv_ephemeral vg.01
73-
if [ "$cfn_encrypted_ephemeral" == "true" ]; then
74-
mkfs -q /dev/ram1 1024
75-
mkdir -p /root/keystore
76-
mount /dev/ram1 /root/keystore
77-
dd if=/dev/urandom of=/root/keystore/keyfile bs=1024 count=4
78-
chmod 0400 /root/keystore/keyfile
79-
cryptsetup -q luksFormat /dev/vg.01/lv_ephemeral /root/keystore/keyfile
80-
cryptsetup -d /root/keystore/keyfile luksOpen /dev/vg.01/lv_ephemeral ephemeral_luks
81-
mkfs.xfs /dev/mapper/ephemeral_luks
82-
mount -v -t xfs -o noatime,nodiratime /dev/mapper/ephemeral_luks /scratch
83-
else
84-
mkfs.xfs /dev/vg.01/lv_ephemeral
85-
echo "/dev/vg.01/lv_ephemeral /scratch xfs noatime,nodiratime 0 0" >> /etc/fstab
86-
mount -v /scratch
87-
fi
88-
chmod 1777 /scratch
28+
# LVM stripe, format, mount ephemeral drives
29+
setup_ephemeral_drives
8930

9031
# Mount NFS exports
9132
RC=0
@@ -128,19 +69,7 @@ if [ $RC -ne 0 ]; then
12869
fi
12970

13071
# Run postinstall script if defined
131-
RC=0
132-
if [ "${cfn_postinstall}" != "NONE" ]; then
133-
tmpfile=$(mktemp)
134-
wget -qO- ${cfn_postinstall} > $tmpfile || RC=1
135-
if [ "${cfn_postinstall_args}" != "NONE" ]; then
136-
args=${cfn_postinstall_args}
137-
fi
138-
/bin/sh $tmpfile $args || RC=1
139-
/bin/rm $tmpfile
140-
fi
141-
if [ $RC -ne 0 ]; then
142-
error_exit "Failed to run boot_as_compute postinstall"
143-
fi
72+
run_postinstall
14473

14574
# Notify compute is ready
14675
instance_id_url="http://169.254.169.254/latest/meta-data/instance-id"

bootstrap/src/scripts/boot_as_master

Lines changed: 7 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,14 @@
1313

1414
set -x
1515

16+
# Source config
1617
. /opt/cfncluster/cfnconfig
1718

18-
function error_exit () {
19-
script=`basename $0`
20-
echo "cfncluster: $script - $1"
21-
logger -t cfncluster "$script - $1"
22-
exit 1
23-
}
19+
# Source functions
20+
. /opt/cfncluster/scripts/functions.shlib
2421

2522
# Run preinstall script if defined
26-
RC=0
27-
if [ "${cfn_preinstall}" != "NONE" ]; then
28-
tmpfile=$(mktemp)
29-
wget -qO- ${cfn_preinstall} > $tmpfile || RC=1
30-
if [ "${cfn_preinstall_args}" != "NONE" ]; then
31-
args=${cfn_preinstall_args}
32-
fi
33-
/bin/sh $tmpfile $args || RC=1
34-
/bin/rm $tmpfile
35-
fi
36-
if [ $RC -ne 0 ]; then
37-
error_exit "Failed to run boot_as_master preinstall"
38-
fi
23+
run_preinstall
3924

4025
## Non-scheduler specific functions
4126
##
@@ -59,52 +44,8 @@ if [ $RC -ne 0 ]; then
5944
error_exit "Failed to enable NAT(PAT)"
6045
fi
6146

62-
# LVM, format, mount /ephemeral
63-
RC=0
64-
mkdir -p /scratch
65-
chmod 1777 /scratch
66-
MAPPING=$(/usr/bin/ec2-metadata -b | grep ephemeral | awk '{print $2}' | sed 's/sd/xvd/')
67-
for m in $MAPPING; do
68-
stat -t /dev/${m} >/dev/null 2>&1
69-
check=$?
70-
if [ ${check} -eq 0 ]; then
71-
DEVS="${m} $DEVS"
72-
fi
73-
done
74-
NUM_DEVS=0
75-
for d in $DEVS; do
76-
d=/dev/${d}
77-
dd if=/dev/zero of=${d} bs=32k count=1
78-
parted -s ${d} mklabel msdos
79-
parted -s ${d}
80-
parted -s -a optimal ${d} mkpart primary 1MB 100%
81-
parted -s ${d} set 1 lvm on
82-
let NUM_DEVS++
83-
PARTITIONS="${d}1 $PARTITIONS"
84-
done
85-
# sleep 10 seconds to let partitions settle (bug?)
86-
sleep 10
87-
88-
# Setup LVM
89-
pvcreate $PARTITIONS
90-
vgcreate vg.01 $PARTITIONS
91-
lvcreate -i $NUM_DEVS -I 64 -l 100%FREE -n lv_ephemeral vg.01
92-
if [ "$cfn_encrypted_ephemeral" == "true" ]; then
93-
mkfs -q /dev/ram1 1024
94-
mkdir -p /root/keystore
95-
mount /dev/ram1 /root/keystore
96-
dd if=/dev/urandom of=/root/keystore/keyfile bs=1024 count=4
97-
chmod 0400 /root/keystore/keyfile
98-
cryptsetup -q luksFormat /dev/vg.01/lv_ephemeral /root/keystore/keyfile
99-
cryptsetup -d /root/keystore/keyfile luksOpen /dev/vg.01/lv_ephemeral ephemeral_luks
100-
mkfs.xfs /dev/mapper/ephemeral_luks
101-
mount -v -t xfs -o noatime,nodiratime /dev/mapper/ephemeral_luks /scratch
102-
else
103-
mkfs.xfs /dev/vg.01/lv_ephemeral
104-
echo "/dev/vg.01/lv_ephemeral /scratch xfs noatime,nodiratime 0 0" >> /etc/fstab
105-
mount -v /scratch
106-
fi
107-
chmod 1777 /scratch
47+
# LVM stripe, format, mount ephemeral drives
48+
setup_ephemeral_drives
10849

10950
# Attach and mount /shared volume
11051
RC=0
@@ -214,16 +155,4 @@ fi
214155
cd /opt/cfncluster/sqswatcher && ./sqswatcher.py 2>&1
215156

216157
# Run postinstall script if defined
217-
RC=0
218-
if [ "${cfn_postinstall}" != "NONE" ]; then
219-
tmpfile=$(mktemp)
220-
wget -qO- ${cfn_postinstall} > $tmpfile || RC=1
221-
if [ "${cfn_postinstall_args}" != "NONE" ]; then
222-
args=${cfn_postinstall_args}
223-
fi
224-
/bin/sh $tmpfile $args || RC=1
225-
/bin/rm $tmpfile
226-
fi
227-
if [ $RC -ne 0 ]; then
228-
error_exit "Failed to run boot_as_master postinstall"
229-
fi
158+
run_postinstall

bootstrap/src/scripts/functions.shlib

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the
2+
# License. A copy of the License is located at
3+
#
4+
# http://aws.amazon.com/asl/
5+
#
6+
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
7+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
8+
# limitations under the License.
9+
10+
# Error exit function
11+
function error_exit () {
12+
script=`basename $0`
13+
echo "cfncluster: $script - $1"
14+
logger -t cfncluster "$script - $1"
15+
exit 1
16+
}
17+
18+
# Check and run preinstall
19+
function run_preinstall () {
20+
RC=0
21+
if [ "${cfn_preinstall}" != "NONE" ]; then
22+
tmpfile=$(mktemp)
23+
wget -qO- ${cfn_preinstall} > $tmpfile || RC=1
24+
if [ "${cfn_preinstall_args}" != "NONE" ]; then
25+
args=${cfn_preinstall_args}
26+
fi
27+
/bin/sh $tmpfile $args || RC=1
28+
/bin/rm $tmpfile
29+
fi
30+
if [ $RC -ne 0 ]; then
31+
error_exit "Failed to run boot_as_master preinstall"
32+
fi
33+
}
34+
35+
# LVM stripe, format, mount ephemeral drives
36+
function setup_ephemeral_drives () {
37+
RC=0
38+
mkdir -p ${cfn_ephemeral_dir} || RC=1
39+
chmod 1777 ${cfn_ephemeral_dir} || RC=1
40+
MAPPING=$(/usr/bin/ec2-metadata -b | grep ephemeral | awk '{print $2}' | sed 's/sd/xvd/')
41+
NUM_DEVS=0
42+
for m in $MAPPING; do
43+
stat -t /dev/${m} >/dev/null 2>&1
44+
check=$?
45+
if [ ${check} -eq 0 ]; then
46+
DEVS="${m} $DEVS"
47+
let NUM_DEVS++
48+
fi
49+
done
50+
if [ $NUM_DEVS -gt 0 ]; then
51+
for d in $DEVS; do
52+
d=/dev/${d}
53+
dd if=/dev/zero of=${d} bs=32k count=1 || RC=1
54+
parted -s ${d} mklabel msdos || RC=1
55+
parted -s ${d} || RC=1
56+
parted -s -a optimal ${d} mkpart primary 1MB 100% || RC=1
57+
parted -s ${d} set 1 lvm on || RC=1
58+
PARTITIONS="${d}1 $PARTITIONS"
59+
done
60+
if [ $RC -ne 0 ]; then
61+
error_exit "Failed to detect and/or partition ephemeral devices."
62+
fi
63+
64+
# sleep 10 seconds to let partitions settle (bug?)
65+
sleep 10
66+
67+
# Setup LVM
68+
RC=0
69+
pvcreate $PARTITIONS || RC=1
70+
vgcreate vg.01 $PARTITIONS || RC=1
71+
lvcreate -i $NUM_DEVS -I 64 -l 100%FREE -n lv_ephemeral vg.01 || RC=1
72+
if [ "$cfn_encrypted_ephemeral" == "true" ]; then
73+
mkfs -q /dev/ram1 1024 || RC=1
74+
mkdir -p /root/keystore || RC=1
75+
mount /dev/ram1 /root/keystore || RC=1
76+
dd if=/dev/urandom of=/root/keystore/keyfile bs=1024 count=4 || RC=1
77+
chmod 0400 /root/keystore/keyfile || RC=1
78+
cryptsetup -q luksFormat /dev/vg.01/lv_ephemeral /root/keystore/keyfile || RC=1
79+
cryptsetup -d /root/keystore/keyfile luksOpen /dev/vg.01/lv_ephemeral ephemeral_luks || RC=1
80+
mkfs.xfs /dev/mapper/ephemeral_luks || RC=1
81+
mount -v -t xfs -o noatime,nodiratime /dev/mapper/ephemeral_luks ${cfn_ephemeral_dir} || RC=1
82+
else
83+
mkfs.xfs /dev/vg.01/lv_ephemeral || RC=1
84+
echo "/dev/vg.01/lv_ephemeral ${cfn_ephemeral_dir} xfs noatime,nodiratime 0 0" >> /etc/fstab || RC=1
85+
mount -v ${cfn_ephemeral_dir} || RC=1
86+
fi
87+
fi
88+
chmod 1777 ${cfn_ephemeral_dir} || RC=1
89+
if [ $RC -ne 0 ]; then
90+
error_exit "Failed to create LVM stripe and/or format ephemeral volume."
91+
fi
92+
}
93+
94+
# Run post install
95+
function run_postinstall () {
96+
RC=0
97+
if [ "${cfn_postinstall}" != "NONE" ]; then
98+
tmpfile=$(mktemp)
99+
wget -qO- ${cfn_postinstall} > $tmpfile || RC=1
100+
if [ "${cfn_postinstall_args}" != "NONE" ]; then
101+
args=${cfn_postinstall_args}
102+
fi
103+
/bin/sh $tmpfile $args || RC=1
104+
/bin/rm $tmpfile
105+
fi
106+
if [ $RC -ne 0 ]; then
107+
error_exit "Failed to run boot_as_master postinstall"
108+
fi
109+
}

cli/cfncluster/cfnconfig.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ def __init__(self, args):
148148
self.__cluster_options = dict(cluster_user='ClusterUser', compute_instance_type='ComputeInstanceType',
149149
master_instance_type='MasterInstanceType', initial_queue_size='InitialQueueSize',
150150
max_queue_size='MaxQueueSize', maintain_initial_size='MaintainInitialSize',
151-
scheduler='Scheduler', cluster_type='ClusterType',
151+
scheduler='Scheduler', cluster_type='ClusterType', ephemeral_dir='EphemeralDir',
152152
spot_price='SpotPrice', custom_ami='CustomAMI', pre_install='PreInstallScript',
153153
post_install='PostInstallScript', proxy_server='ProxyServer',
154-
iam_policy='IAMPolicy', placement='Placement', placement_group='PlacementGroup',
154+
placement='Placement', placement_group='PlacementGroup',
155155
encrypted_ephemeral='EncryptedEphemeral',pre_install_args='PreInstallArgs',
156-
post_install_args='PostInstallArgs')
156+
post_install_args='PostInstallArgs', s3_read_resource='S3ReadResource',
157+
s3_read_write_resource='S3ReadWriteResource')
157158

158159
# Loop over all the cluster options and add define to parameters, raise Exception if defined but null
159160
for key in self.__cluster_options:

cli/cfncluster/examples/config

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ key_name = mykey
5454
#spot_price = 0.00
5555
# ID of a Custom AMI, to use instead of published AMI's
5656
#custom_ami = NONE
57+
# Specify S3 resource which cfncluster nodes will be granted read-only access
58+
# (defaults to NONE for the default template)
59+
#s3_read_resource = NONE
60+
# Specify S3 resource which cfncluster nodes will be granted read-write access
61+
# (defaults to NONE for the default template)
62+
#s3_read_write_resource = NONE
5763
# URL to a preinstall script. This is executed before any of the boot_as_* scripts are run
5864
# (defaults to NONE for the default template)
5965
#pre_install = NONE
@@ -74,7 +80,10 @@ key_name = mykey
7480
#placement_group = NONE
7581
# Cluster placment logic. This enables the whole cluster or only compute to use the placement group
7682
# (defaults to cluster in the default template)
77-
#placement = cluster
83+
#placement = cluster
84+
# Path/mountpoint for ephemeral drives
85+
# (defaults to /scratch in the default template)
86+
#ephemeral_dir = /scratch
7887
# Encrypted ephemeral drives. In-memory keys, non-recoverable.
7988
# (defaults to false in default template)
8089
#encrypted_ephemeral = false

0 commit comments

Comments
 (0)