Update 'heat_homework.yml'

This commit is contained in:
Torma Kristóf 2020-05-08 02:32:59 +02:00
parent 98319036df
commit 8ecb05d889

View File

@ -1,17 +1,13 @@
heat_template_version: 2013-05-23 heat_template_version: 2013-05-23
description: > description: >
Heat WordPress template to support F20, using only Heat OpenStack-native Fantastic HEAT teamplate that creates a wonderful Wordpress website.
resource types, and without the requirement for heat-cfntools in the image. Homework of Cloud networking (BMEVITMMA02).
WordPress is web software you can use to create a beautiful website or blog. NEPTUN: Y8O353
This template installs a single-instance WordPress deployment using a local Name: Kristof Torma
MySQL database to store the data. Copyright, all memes reserved.
parameters: parameters:
key_name:
type: string
description: Name of a KeyPair to enable SSH access to the instance
instance_type: instance_type:
type: string type: string
description: Instance type for WordPress server description: Instance type for WordPress server
@ -27,18 +23,23 @@ parameters:
private_net_name: private_net_name:
type: string type: string
description: Name of private network to be created description: Name of private network to be created
default: private-netw
private_net_cidr: private_net_cidr:
type: string type: string
description: Private network address (CIDR notation) description: Private network address (CIDR notation)
default: 192.168.69.0/24
private_net_gateway: private_net_gateway:
type: string type: string
description: Private network gateway address description: Private network gateway address
default: 192.168.69.1
private_net_pool_start: private_net_pool_start:
type: string type: string
description: Start of private network IP address allocation pool description: Start of private network IP address allocation pool
default: 192.168.69.2
private_net_pool_end: private_net_pool_end:
type: string type: string
description: End of private network IP address allocation pool description: End of private network IP address allocation pool
default: 192.168.69.254
db_name: db_name:
type: string type: string
description: WordPress database name description: WordPress database name
@ -92,7 +93,7 @@ resources:
private_subnet: private_subnet:
type: OS::Neutron::Subnet type: OS::Neutron::Subnet
properties: properties:
dns_nameservers: "8.8.8.8" dns_nameservers: [ "8.8.8.8" ]
network_id: { get_resource: private_net } network_id: { get_resource: private_net }
cidr: { get_param: private_net_cidr } cidr: { get_param: private_net_cidr }
gateway_ip: { get_param: private_net_gateway } gateway_ip: { get_param: private_net_gateway }
@ -104,7 +105,7 @@ resources:
type: OS::Neutron::Router type: OS::Neutron::Router
properties: properties:
external_gateway_info: external_gateway_info:
network: ext_net network: ext-net
router_interface: router_interface:
type: OS::Neutron::RouterInterface type: OS::Neutron::RouterInterface
@ -115,10 +116,8 @@ resources:
db_instance: db_instance:
type: OS::Nova::Server type: OS::Nova::Server
properties: properties:
security_groups: [{ get_resource: db_security_group }]
image: { get_param: image_id } image: { get_param: image_id }
flavor: { get_param: instance_type } flavor: { get_param: instance_type }
key_name: { get_param: key_name }
networks: networks:
- port: { get_resource: db_port } - port: { get_resource: db_port }
user_data: user_data:
@ -135,7 +134,7 @@ resources:
mysqladmin -u root password db_rootpassword mysqladmin -u root password db_rootpassword
cat << EOF | mysql -u root --password=db_rootpassword cat << EOF | mysql -u root --password=db_rootpassword
CREATE DATABASE db_name; CREATE DATABASE db_name;
GRANT ALL PRIVILEGES ON db_name.* TO "db_user"@"localhost" GRANT ALL PRIVILEGES ON db_name.* TO "db_user"@"%"
IDENTIFIED BY "db_password"; IDENTIFIED BY "db_password";
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
EXIT EXIT
@ -150,6 +149,7 @@ resources:
type: OS::Neutron::Port type: OS::Neutron::Port
properties: properties:
network_id: { get_resource: private_net } network_id: { get_resource: private_net }
security_groups: [{ get_resource: db_security_group }]
fixed_ips: fixed_ips:
- subnet_id: { get_resource: private_subnet } - subnet_id: { get_resource: private_subnet }
@ -159,7 +159,7 @@ resources:
description: Add security group rules for Wordpress description: Add security group rules for Wordpress
name: mariadb-security-group name: mariadb-security-group
rules: rules:
- remote_ip_prefix: { get_resource: private_subnet } - remote_ip_prefix: { get_param: private_net_cidr }
protocol: tcp protocol: tcp
port_range_min: 3306 port_range_min: 3306
port_range_max: 3306 port_range_max: 3306
@ -173,10 +173,8 @@ resources:
webs_instance: webs_instance:
type: OS::Nova::Server type: OS::Nova::Server
properties: properties:
security_groups: [{ get_resource: web_security_group }]
image: { get_param: image_id } image: { get_param: image_id }
flavor: { get_param: instance_type } flavor: { get_param: instance_type }
key_name: { get_param: key_name }
networks: networks:
- port: { get_resource: web_port } - port: { get_resource: web_port }
user_data: user_data:
@ -190,6 +188,9 @@ resources:
sed -i s/database_name_here/db_name/ /etc/wordpress/wp-config.php sed -i s/database_name_here/db_name/ /etc/wordpress/wp-config.php
sed -i s/username_here/db_user/ /etc/wordpress/wp-config.php sed -i s/username_here/db_user/ /etc/wordpress/wp-config.php
sed -i s/password_here/db_password/ /etc/wordpress/wp-config.php sed -i s/password_here/db_password/ /etc/wordpress/wp-config.php
sed -i s/localhost/db_ipaddr/ /etc/wordpress/wp-config.php
setsebool -P httpd_can_network_connect_db 1
systemctl start httpd.service systemctl start httpd.service
params: params:
@ -197,18 +198,20 @@ resources:
db_name: { get_param: db_name } db_name: { get_param: db_name }
db_user: { get_param: db_username } db_user: { get_param: db_username }
db_password: { get_param: db_password } db_password: { get_param: db_password }
db_ipaddr: { get_attr: [ db_instance, first_address ] }
web_port: web_port:
type: OS::Neutron::Port type: OS::Neutron::Port
properties: properties:
network_id: { get_resource: private_net } network_id: { get_resource: private_net }
security_groups: [{ get_resource: web_security_group }]
fixed_ips: fixed_ips:
- subnet_id: { get_resource: private_subnet } - subnet_id: { get_resource: private_subnet }
web_floating_ip: web_floating_ip:
type: OS::Neutron::FloatingIP type: OS::Neutron::FloatingIP
properties: properties:
floating_network: ext_net floating_network: ext-net
port_id: { get_resource: web_port } port_id: { get_resource: web_port }
web_security_group: web_security_group:
@ -239,4 +242,4 @@ outputs:
str_replace: str_replace:
template: http://host/wordpress template: http://host/wordpress
params: params:
host: { get_attr: [wordpress_instance, first_address] } host: { get_attr: [web_floating_ip, floating_ip_address] }