-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflex_lamp_stack.yaml
126 lines (115 loc) · 3.77 KB
/
flex_lamp_stack.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: 2018-08-31
description: >
This Heat template provisions a virtual machine on OpenStack with a specified flavor, image, and SSH key, sets up a private network and subnet, configures routing to an external network, and installs a LAMP stack (Linux, Apache, MySQL, PHP) on the instance. It includes security group rules to allow SSH, HTTP, and HTTPS access and assigns a floating IP to the instance for public accessibility.
parameters:
flavor:
type: string
description: Flavor of the instance
default: $FLAVOR_NAME
image:
type: string
description: Image to use for the instance
default: $IMAGE_ID
key_name:
type: string
description: Name of the SSH key to use
default: $KEY_NAME
public_net_id:
type: string
description: ID of the public network
default: $PUBLICNET_ID
resources:
private_net:
type: OS::Neutron::Net
properties:
name: private_net
private_subnet:
type: OS::Neutron::Subnet
properties:
network_id: { get_resource: private_net }
cidr: "192.168.0.0/24"
gateway_ip: "192.168.0.1"
ip_version: 4
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_id }
router_interface:
type: OS::Neutron::RouterInterface
properties:
router_id: { get_resource: router }
subnet_id: { get_resource: private_subnet }
instance_port:
type: OS::Neutron::Port
properties:
network_id: { get_resource: private_net }
security_groups: [{ get_resource: instance_security_group }]
instance_security_group:
type: OS::Neutron::SecurityGroup
properties:
name: instance_security_group
description: Security group for the instance
rules:
- direction: ingress
ethertype: IPv4
protocol: tcp
port_range_min: 22
port_range_max: 22
- direction: ingress
ethertype: IPv4
protocol: icmp
- direction: ingress
ethertype: IPv4
protocol: tcp
port_range_min: 80
port_range_max: 80
- direction: ingress
ethertype: IPv4
protocol: tcp
port_range_min: 443
port_range_max: 443
floating_ip:
type: OS::Neutron::FloatingIP
properties:
floating_network_id: { get_param: public_net_id }
port_id: { get_resource: instance_port }
instance:
type: OS::Nova::Server
properties:
flavor: { get_param: flavor }
image: { get_param: image }
key_name: { get_param: key_name }
networks:
- port: { get_resource: instance_port }
user_data:
str_replace:
template: |
#!/bin/bash
# Update and install Apache
apt-get update -y
apt-get install -y apache2
# Start Apache service
systemctl start apache2
systemctl enable apache2
# Install MySQL
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
apt-get install -y mysql-server
# Install PHP
apt-get install -y php libapache2-mod-php php-mysql
# Restart Apache to load PHP
systemctl restart apache2
params:
"$FLAVOR_NAME": { get_param: flavor }
"$IMAGE_ID": { get_param: image }
"$KEY_NAME": { get_param: key_name }
"$PUBLICNET_ID": { get_param: public_net_id }
outputs:
instance_ip:
description: IP address of the instance
value: { get_attr: [floating_ip, floating_ip_address] }