Skip to content

Commit 36bf746

Browse files
author
Dougal Ballantyne
committed
Merge branch 'master' of github.com:awslabs/cfncluster
2 parents 9b39cf7 + 930d822 commit 36bf746

File tree

11 files changed

+271
-210
lines changed

11 files changed

+271
-210
lines changed

CHANGELOG.rst

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

5+
0.0.12
6+
======
7+
8+
* updates:``cli``: Simplfied VPC config and removed multi-AZ
9+
10+
511
0.0.11
612
======
713

README.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ everything is done using CloudFormation or resources within AWS.
88

99
### Installation
1010

11-
The current working version is cfncluster-0.0.11. The CLI is written in python and uses BOTO for AWS actions. You can install the CLI with the following command:
11+
The current working version is cfncluster-0.0.12. The CLI is written in python and uses BOTO for AWS actions. You can install the CLI with the following command:
1212

1313
#### Linux/OSX
1414

1515
```
16-
$ sudo easy_install cfncluster
16+
$ sudo pip install cfncluster
1717
```
1818
or
1919
```
20-
$ sudo pip install cfncluster
20+
$ sudo easy_install cfncluster
2121
```
2222

2323
#### Windows
@@ -31,6 +31,26 @@ setuptools - https://pypi.python.org/pypi/setuptools#windows-7-or-graphical-inst
3131

3232
Once installed, you should update the Environment Variables to have the Python install directory and Python Scripts directory in the PATH, for example: C:\Python27;C:\Python27\Scripts
3333

34+
Now it should be possible to run the following within a command prompt window:
35+
36+
```
37+
C:\> easy_install cfncluster
38+
```
39+
40+
#### Upgrading
41+
42+
To upgrade an older version of cfncluster, you can use either of the following commands, depening on how it was originally installed:
43+
44+
```
45+
$ sudo pip install --upgrade cfncluster
46+
```
47+
or
48+
```
49+
$ sudo easy_install -U cfncluster
50+
```
51+
52+
** Remember when upgrading to check that the exiting config is compatible with the latest version installed.
53+
3454
### Configuration
3555

3656
Once installed you will need to setup some initial config. The easiest way to do this is below:
@@ -45,30 +65,29 @@ $ mkdir ~/.cfncluster
4565
$ cp /usr/lib/python2.6/site-packages/cfncluster/examples/config ~/.cfncluster
4666
```
4767

48-
You should now edit the config and set some defaults before launching the cluster. First define a keypair that already exists in EC2.
68+
You should now edit the config and set some defaults before launching the cluster. First define a keypair that already exists in EC2. If you do not already have a keypair, refer to the EC2 documentation on EC2 Key Pairs - http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
4969

5070
```
5171
[keypair mykey]
5272
key_location = /path/to/key.pem
73+
````
74+
5375
Then you should associate that keypair with the cluster template.
76+
````
5477
[cluster default]
5578
# Name of an existing EC2 KeyPair to enable SSH access to the instances.
5679
key_name = mykey
5780
```
5881

59-
Finally, a base cluster launches into a VPC and uses an existing subnet which supports public IP's i.e. the route table for the subnet is 0.0.0.0/0 => igw-xxxxxx. The VPC must have "DNS Resolution = yes" and "DNS Hostnames = yes". It should also have DHCP options with the correct "domain-name" for the region, as defined in the docs: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html
82+
Next, a simple cluster launches into a VPC and uses an existing subnet which supports public IP's i.e. the route table for the subnet is 0.0.0.0/0 => igw-xxxxxx. The VPC must have "DNS Resolution = yes" and "DNS Hostnames = yes". It should also have DHCP options with the correct "domain-name" for the region, as defined in the docs: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html
6083

6184
```
6285
## VPC Settings
6386
[vpc public]
6487
# ID of the VPC you want to provision cluster into.
65-
vpc_id = vpc-
88+
vpc_id = CHANGE ME, for example vpc-a1b2c3d4
6689
# ID of the Subnet you want to provision the Master server into
67-
public_subnet = subnet-
68-
# Availability zones of VPC resources
69-
# This is a comma delimited list and must always contain three values
70-
# Example: us-west-2a,NONE,NONE
71-
availability_zones =
90+
master_subnet_id = CHANGE ME, for exaple subnet-1ab2c3d4
7291
```
7392

7493
Once all of those settings contain valid values, you can launch the cluster by repeating the command that was used at the start.

bootstrap/src/scripts/boot_as_master

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ if [ $RC -ne 0 ]; then
135135
error_exit "Failed to start Ganglia"
136136
fi
137137

138-
# Setup ec2-user SSH auth
138+
# Setup ${cfn_cluster_user} SSH auth
139139
RC=0
140-
su - ec2-user -c "ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ''" || RC=1
141-
su - ec2-user -c "cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys2 && chmod 0600 ~/.ssh/authorized_keys2" || RC=1
142-
su - ec2-user -c "ssh-keyscan ${myhostname} > ~/.ssh/known_hosts && chmod 0600 ~/.ssh/known_hosts" || RC=1
140+
su - ${cfn_cluster_user} -c "ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ''" || RC=1
141+
su - ${cfn_cluster_user} -c "cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys2 && chmod 0600 ~/.ssh/authorized_keys2" || RC=1
142+
su - ${cfn_cluster_user} -c "ssh-keyscan ${myhostname} > ~/.ssh/known_hosts && chmod 0600 ~/.ssh/known_hosts" || RC=1
143143
if [ $RC -ne 0 ]; then
144-
error_exit "Failed to setup ec2-user SSH auth"
144+
error_exit "Failed to setup ${cfn_cluster_user} SSH auth"
145145
fi
146146

147147
## Scheduler specific section

cli/cfncluster/cfncluster.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import boto.cloudformation
1414
import boto.ec2.autoscale
15+
import boto.vpc
1516
import boto.exception
1617
import time
1718
import os
@@ -25,14 +26,32 @@
2526
def create(args):
2627
print('Starting: %s' % (args.cluster_name))
2728

29+
# Build the config based on args
2830
config = cfnconfig.CfnClusterConfig(args)
31+
32+
# Set the ComputeWaitConditionCount parameter to match InitialQueueSize
2933
try:
3034
i = [p[0] for p in config.parameters].index('InitialQueueSize')
3135
initial_queue_size = config.parameters[i][1]
3236
config.parameters.append(('ComputeWaitConditionCount', initial_queue_size))
3337
except ValueError:
3438
pass
3539

40+
# Get the MasterSubnetId and use it to determine AvailabilityZone
41+
try:
42+
i = [p[0] for p in config.parameters].index('MasterSubnetId')
43+
master_subnet_id = config.parameters[i][1]
44+
try:
45+
vpcconn = boto.vpc.connect_to_region(config.region,aws_access_key_id=config.aws_access_key_id,
46+
aws_secret_access_key=config.aws_secret_access_key)
47+
availability_zone = str(vpcconn.get_all_subnets(subnet_ids=master_subnet_id)[0].availability_zone)
48+
except boto.exception.BotoServerError as e:
49+
print e.message
50+
sys.exit(1)
51+
config.parameters.append(('AvailabilityZone', availability_zone))
52+
except ValueError:
53+
pass
54+
3655
capabilities = ["CAPABILITY_IAM"]
3756
cfnconn = boto.cloudformation.connect_to_region(config.region,aws_access_key_id=config.aws_access_key_id,
3857
aws_secret_access_key=config.aws_secret_access_key)

cli/cfncluster/cfnconfig.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,27 @@ def __init__(self, args):
117117
self.aws_secret_access_key=None
118118

119119
# Determine the CloudFormation URL to be used
120-
# Config file or default
120+
# Order is 1) CLI arg 2) Config file 3) default for version + region
121121
try:
122-
self.template_url = __config.get(self.__cluster_section,
123-
'template_url')
124-
if not self.template_url:
125-
raise Exception
126-
except ConfigParser.NoOptionError:
127-
self.template_url = ('https://s3.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json' % (self.region, self.version))
122+
if args.template_url is not None:
123+
self.template_url = args.template_url
124+
try:
125+
self.template_url = __config.get(self.__cluster_section,
126+
'template_url')
127+
if not self.template_url:
128+
raise Exception
129+
except ConfigParser.NoOptionError:
130+
self.template_url = ('https://s3.amazonaws.com/cfncluster-%s/templates/cfncluster-%s.cfn.json' % (self.region, self.version))
131+
except AttributeError:
132+
pass
128133

129134
# Determine which vpc settings section will be used
130135
self.__vpc_settings = __config.get(self.__cluster_section, 'vpc_settings')
131136
self.__vpc_section = ('vpc %s' % self.__vpc_settings)
132137

133138
# Dictionary list of all VPC options
134-
self.__vpc_options = dict(vpc_id='VPCId', public_subnet='PublicSubnet', private_cidrs='PrivateCIDRs',
135-
vpc_base_eni='VPCBaseNATENI1', compute_uses_public_subnet='ComputeUsesPublicSubnet',
136-
vpc_base_security_group='VPCBaseBackSecurityGroup', use_vpc_base='UseVPCBase',
137-
vpc_base_backend_subnet='VPCBaseBackendSubnet1',
138-
availability_zones='AvailabilityZones', ssh_from='SSHFrom')
139+
self.__vpc_options = dict(vpc_id='VPCId', master_subnet_id='MasterSubnetId', compute_subnet_cidr='ComputeSubnetCidr',
140+
compute_subnet_id='ComputeSubnetId', use_public_ips='UsePublicIps' , ssh_from='SSHFrom')
139141

140142
# Loop over all VPC options and add define to parameters, raise Exception is defined but null
141143
for key in self.__vpc_options:

cli/cfncluster/examples/config

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,33 +99,27 @@ vpc_settings = public
9999
# ID of the VPC you want to provision cluster into.
100100
vpc_id = vpc-
101101
# ID of the Subnet you want to provision the Master server into
102-
public_subnet = subnet-
103-
# Availability zones of VPC resources
104-
# This is a comma delimited list and must always contain three values
105-
# Example: us-west-2a,NONE,NONE
106-
availability_zones =
102+
master_subnet_id = subnet-
107103
# SSH from CIDR
108104
# This is only used when cfncluster creates the security group
109105
# (defaults to 0.0.0.0/0 in the default template)
110106
#ssh_from = 0.0.0.0/0
111107

112-
#[vpc private]
113-
# Boolean flag to launch compute with direct egress or behind the Master server.
114-
#compute_uses_public_subnet = false
115-
# ID of the VPC you want to provision cluster into. Only used with UseVPCBase=false
116-
#vpc_id =
108+
#[vpc private-new]
109+
# ID of the VPC you want to provision cluster into.
110+
#vpc_id = vpc-
117111
# ID of the Subnet you want to provision the Master server into
118-
#public_subnet =
112+
#master_subnet_id = subnet-
119113
# CIDR for new backend subnet i.e. 10.0.100.0/24
120-
#private_cidrs = 10.0.100.0/24
114+
#compute_subnet_cidr = 10.0.100.0/24
121115

122-
#[vpc existing-public]
123-
# Boolean flag to use exisiting vpc resources from vpc or create resources
124-
#use_vpc_base = true
125-
# Id of existing ENI to be used for the master serer
126-
#vpc_base_eni = eni-
127-
# Exisiting Compute Security Group ID
128-
#vpc_base_security_group = sg-
116+
#[vpc private-existing]
117+
# ID of the VPC you want to provision cluster into.
118+
#vpc_id =
119+
# ID of the Subnet you want to provision the Master server into
120+
#master_subnet_id = subnet-
121+
# CIDR for new backend subnet i.e. 10.0.100.0/24
122+
#compute_subnet_id = subnet-
129123

130124
## EBS Settings
131125
#[ebs custom]

cli/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def read(fname):
2020
return open(os.path.join(os.path.dirname(__file__), fname)).read()
2121

2222
console_scripts = ['cfncluster = cfncluster.cli:main']
23-
version = "0.0.11"
24-
requires = ['boto', 'botocore']
23+
version = "0.0.12"
24+
requires = ['boto>=2.32.1', 'botocore']
2525

2626
if sys.version_info[:2] == (2, 6):
2727
# For python2.6 we have to require argparse since it

0 commit comments

Comments
 (0)