-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflex_wordpress_instance.yaml
129 lines (118 loc) · 3.83 KB
/
flex_wordpress_instance.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
127
128
129
heat_template_version: 2018-03-02
description: >
HOT template to deploy a WordPress server on OpenStack. This will create the necessary network infrastructure, security groups, and a VM instance. You will need to log into your server's wp-admin URL to complete the installation
parameters:
private_net_cidr:
type: string
default: 10.0.0.0/24
description: CIDR for the private network
private_net_gateway:
type: string
default: 10.0.0.1
description: Gateway for the private network
image:
type: string
default: 'ubuntu-20.04'
description: Image to use for the VM instance
flavor:
type: string
default: 'm1.small'
description: Flavor to use for the VM instance
public_net:
type: string
default: 46b9a179-8b26-40fa-b3ed-0927df4251e0
description: Name or ID of the public network
key_name:
type: string
description: Name of the key pair to use for the VM instance
resources:
private_network:
type: OS::Neutron::Net
properties:
name: private_network
private_subnet:
type: OS::Neutron::Subnet
properties:
name: private_subnet
network_id: { get_resource: private_network }
cidr: { get_param: private_net_cidr }
gateway_ip: { get_param: private_net_gateway }
dns_nameservers:
- 8.8.8.8
- 8.8.4.4
router:
type: OS::Neutron::Router
properties:
name: router
external_gateway_info:
network: { get_param: public_net }
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: router }
subnet_id: { get_resource: private_subnet }
vm_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: private_network }
security_groups: [{ get_resource: vm_security_group }]
vm_security_group:
type: OS::Neutron::SecurityGroup
properties:
name: vm_security_group
description: Security group for the WordPress VM
rules:
- protocol: tcp
port_range_min: 22
port_range_max: 22
remote_ip_prefix: 0.0.0.0/0
- protocol: tcp
port_range_min: 80
port_range_max: 80
remote_ip_prefix: 0.0.0.0/0
- protocol: tcp
port_range_min: 443
port_range_max: 443
remote_ip_prefix: 0.0.0.0/0
- protocol: icmp
remote_ip_prefix: 0.0.0.0/0
floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: { get_param: public_net }
port_id: { get_resource: vm_port }
wordpress_server:
type: OS::Nova::Server
properties:
name: wordpress_server
image: { get_param: image }
flavor: { get_param: flavor }
key_name: { get_param: key_name }
networks:
- port: { get_resource: vm_port }
user_data_format: RAW
user_data: |
#!/bin/bash
apt-get update
apt-get install -y apache2 mysql-server php php-mysql libapache2-mod-php
mysql -e "CREATE DATABASE wordpress;"
mysql -e "CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';"
mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
rm latest.tar.gz
mv wordpress/* .
rmdir wordpress
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
cp wp-config-sample.php wp-config.php
sed -i "s/database_name_here/wordpress/g" wp-config.php
sed -i "s/username_here/wpuser/g" wp-config.php
sed -i "s/password_here/password/g" wp-config.php
systemctl restart apache2
outputs:
instance_ip:
description: IP address of the WordPress server
value: { get_attr: [floating_ip, floating_ip_address] }