forked from NeCTAR-RC/heat-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordpress.yaml
113 lines (89 loc) · 3.42 KB
/
wordpress.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
# http://docs.openstack.org/developer/heat/template_guide/hot_spec.html#heat-template-version
heat_template_version: 2014-10-16
description: >
Template that installs a wordpress server.
Note it is also used by the environment sample project
parameters:
image:
type: string
description: The Ubuntu image to use.
flavor:
type: string
description: The NeCTAR flavour the webserver is to run on
key:
type: string
description: Name of an existing KeyPair to enable SSH access to the instances
mysql_server:
type: string
description: The IP address of the database server.
database_name:
type: string
description: Name of the application database.
database_user:
type: string
description: The database user name.
database_password:
type: string
hidden: true
description: The dabase password.
resources:
wait_condition:
type: OS::Heat::WaitCondition
properties:
handle: { get_resource: wait_handle }
count: 1
timeout: 600
wait_handle:
type: OS::Heat::WaitConditionHandle
security_group:
type: AWS::EC2::SecurityGroup
properties:
GroupDescription: Web server access rules.
SecurityGroupIngress:
- {IpProtocol: icmp, FromPort: '-1', ToPort: '-1', CidrIp : 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '22', ToPort: '22', CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '80', ToPort: '80', CidrIp: 0.0.0.0/0}
- {IpProtocol: tcp, FromPort: '443', ToPort: '443', CidrIp: 0.0.0.0/0}
wordpress_instance:
type: OS::Nova::Server
properties:
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key }
security_groups:
- { get_resource: security_group }
user_data_format: RAW
user_data:
str_replace:
params:
__mysql_ip__: { get_param: mysql_server }
__database_name__: { get_param: database_name }
__database_user__: { get_param: database_user }
__database_password__: { get_param: database_password }
wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
template: |
#!/bin/bash -ex
# install dependencies
apt-get update
apt-get -y install apache2 php5 libapache2-mod-php5 php5-mysql php5-gd mysql-client
# download wordpress
wget http://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
# configure wordpress
cp wordpress/wp-config-sample.php wordpress/wp-config.php
sed -i 's/database_name_here/__database_name__/' wordpress/wp-config.php
sed -i 's/username_here/__database_user__/' wordpress/wp-config.php
sed -i 's/password_here/__database_password__/' wordpress/wp-config.php
sed -i 's/localhost/__mysql_ip__/' wordpress/wp-config.php
# install a copy of the configured wordpress into apache's www directory
rm /var/www/html/index.html
cp -R wordpress/* /var/www/html/
# give apache ownership of the application files
chown -R www-data:www-data /var/www/html/
chmod -R g+w /var/www/html/
# notify heat that we are done here
wc_notify --data-binary '{"status": "SUCCESS"}'
outputs:
ip:
description: The IP address of the wordpress instance.
value: { get_attr: [wordpress_instance, first_address] }