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