forked from NeCTAR-RC/heat-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenstack_command_line_tools.yaml
117 lines (99 loc) · 4.41 KB
/
openstack_command_line_tools.yaml
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
# http://docs.openstack.org/developer/heat/template_guide/hot_spec.html#heat-template-version
heat_template_version: 2014-10-16
description: >
A NeCTAR sample template that installs some of the OpenStack command line tools on a single Ubuntu instance.
It also asks for your environment variables required to run the tools, and puts them into the
ec2-user environment. The required values are found on the API Access tab of the
https://dashboard.rc.nectar.org.au/project/access_and_security/
parameters:
key_name:
description: Name of an existing KeyPair to enable SSH access to the instances
type: string
auth_url:
description: The Keystone authentication url
default: https://keystone.rc.nectar.org.au:5000/v2.0/
type: string
image_id:
description: The id of the Ubuntu image to use (This default NeCTAR image id may have been retired)
default: 2a882d9c-3185-414c-9683-a4646b5c785e
type: string
tenant_id:
description: Your NeCTAR project id
type: string
tenant_name:
description: Your NeCTAR tenant name
type: string
user_name:
description: The user name that you use to log onto the NeCTAR cloud via the dashboard
type: string
password:
description: The password for command line usage (Not your AAF password!)
hidden: true
type: string
resources:
command_line_tools:
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::EC2::Instance
type: AWS::EC2::Instance
properties:
ImageId: { get_param: image_id }
InstanceType: m1.small
KeyName: { get_param: key_name }
UserData:
str_replace:
template: |
#!/bin/bash -v
# Helper function
function error_exit
{
/opt/aws/bin/cfn-signal -e 1 -r "$1" 'WaitHandle'
exit 1
}
# https://wiki.debian.org/EnvironmentVariables
apt-get update && sudo apt-get -y upgrade
# set the default shell in /etc/passwd to bash for the ec2-user
usermod -s /bin/bash ec2-user
cat >> /home/ec2-user/.profile << EOF
export OS_AUTH_URL=AuthUrl
export OS_TENANT_ID=TenantId
export OS_TENANT_NAME=TenantName
export OS_USERNAME=UserName
export OS_PASSWORD=Password
EOF
apt-get -y install python-ceilometerclient || error_exit 'Failed to install ceilometerclient.'
apt-get -y install python-cinderclient || error_exit 'Failed to install cinderclient.'
apt-get -y install python-glanceclient || error_exit 'Failed to install glanceclient.'
apt-get -y install python-heatclient || error_exit 'Failed to install heatclient.'
apt-get -y install python-keystoneclient || error_exit 'Failed to install keystoneclient.'
apt-get -y install python-novaclient || error_exit 'Failed to install novaclient.'
apt-get -y install python-swiftclient || error_exit 'Failed to install swiftclient.'
apt-get -y install python-troveclient || error_exit 'Failed to install troveclient.'
apt-get -y install python-designateclient || error_exit 'Failed to install designateclient.'
/opt/aws/bin/cfn-signal -e 0 -r "Command line tools server setup complete" 'WaitHandle'
params:
AuthUrl: { get_param: auth_url }
TenantId: { get_param: tenant_id }
TenantName: { get_param: tenant_name }
UserName: { get_param: user_name }
Password: { get_param: password }
WaitHandle: { get_resource: wait_handle }
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::CloudFormation::WaitConditionHandle
wait_handle:
type: 'AWS::CloudFormation::WaitConditionHandle'
# http://docs.openstack.org/developer/heat/template_guide/cfn.html#AWS::CloudFormation::WaitCondition
wait_condition:
type: AWS::CloudFormation::WaitCondition
depends_on: command_line_tools
properties:
Handle: { get_resource: wait_handle }
Count: 1
# we'll give it 15 minutes
Timeout: 900
outputs:
ssh_command:
description: The command to use to ssh into the instance (assuming your key is in ~./ssh/)
value:
str_replace:
template: ssh ec2-user@host -i ~/.ssh/key.pem
params:
host: { get_attr: [command_line_tools, PublicIp] }
key: { get_param: key_name }