-
Notifications
You must be signed in to change notification settings - Fork 2
/
wordpress-ubuntu-env.yaml
126 lines (112 loc) · 3.81 KB
/
wordpress-ubuntu-env.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
118
119
120
121
122
123
124
125
126
heat_template_version: 2013-05-23
description: Template that installs a wordpress server.
parameters:
image:
type: string
label: Image name or ID
description: Image to be used for server. Please use an Ubuntu based image.
default: trusty-server-cloudimg-amd64
flavor:
type: string
label: Flavor
description: Type of instance (flavor) to be used on the compute instance.
default: m1.small
key:
type: string
label: Key name
description: Name of key-pair to be installed on the compute instance.
default: my_key
private_network:
type: string
label: Private network name or ID
description: Network to attach server to.
default: private
mysql_server:
type: string
label: MySQL database server
description: IP address of the MySQL database server.
database_name:
type: string
label: Database name
description: Name of the application database.
database_user:
type: string
label: Database user
description: Name of the database user.
database_password:
type: string
label: Database password
hidden: true
description: Password to access the database.
resources:
wait_condition:
type: OS::Heat::WaitCondition
properties:
handle: { get_resource: wh }
count: 1
timeout: 600
wh:
type: OS::Heat::WaitConditionHandle
security_group:
type: OS::Neutron::SecurityGroup
properties:
name: web_server_security_group
rules:
- protocol: tcp
port_range_min: 80
port_range_max: 80
port:
type: OS::Neutron::Port
properties:
network: { get_param: private_network }
security_groups:
- { get_resource: security_group }
wordpress_instance:
type: OS::Nova::Server
properties:
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key }
networks:
- port: { get_resource: port }
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: ['wh', '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:
name:
description: Name of the wordpress instance.
value: { get_attr: [wordpress_instance, name] }
ip:
description: The IP address of the wordpress instance.
value: { get_attr: [wordpress_instance, first_address] }
port:
description: The network port of the wordpress instance.
value: { get_resource: port }