Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- heat_template_version: 2013-05-23
- parameters:
- #External Network
- public_net:
- type: string
- description: ID or name of public network for which floating IP addresses will be allocated
- default: ext-net
- #Internal Network
- private_net_name:
- type: string
- description: Name of private network to be created
- default: myInternalNetwork
- #IP
- private_net_cidr:
- type: string
- description: Private network address (CIDR notation)
- default: 10.0.1.0/24
- private_net_gateway:
- type: string
- description: Private network gateway address
- default: 10.0.1.1
- #URL: http://git.openstack.org/cgit/openstack/heat-templates/plain/hot/F20/WordPress_Native.yaml
- #WordPress
- key_name:
- type: string
- description: Name of a KeyPair to enable SSH access to the instance
- default: superkey
- instance_type:
- type: string
- description: Instance type for WordPress server
- default: m1.small
- image_id:
- type: string
- description: >
- Name or ID of the image to use for the WordPress server.
- default: fedora-21.x86_64
- db_name:
- type: string
- description: WordPress database name
- default: wordpress
- constraints:
- - length: { min: 1, max: 64 }
- description: db_name must be between 1 and 64 characters
- - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*'
- description: >
- db_name must begin with a letter and contain only alphanumeric
- characters
- db_username:
- type: string
- description: The WordPress database admin account username
- default: lab4
- constraints:
- - length: { min: 1, max: 16 }
- description: db_username must be between 1 and 16 characters
- - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*'
- description: >
- db_username must begin with a letter and contain only alphanumeric
- characters
- db_password:
- type: string
- description: The WordPress database admin account password
- default: lab4
- constraints:
- - length: { min: 1, max: 41 }
- description: db_password must be between 1 and 41 characters
- - allowed_pattern: '[a-zA-Z0-9]*'
- description: db_password must contain only alphanumeric characters
- db_root_password:
- type: string
- description: Root password for MySQL
- default: lab4
- constraints:
- - length: { min: 1, max: 41 }
- description: db_root_password must be between 1 and 41 characters
- - allowed_pattern: '[a-zA-Z0-9]*'
- description: db_root_password must contain only alphanumeric characters
- resources:
- # -------------- Creating Key --------------------------
- my_key:
- type: OS::Nova::KeyPair
- properties:
- name: my_Key
- save_private_key: true
- # -------------- Internal Network -----------------------
- private_net:
- type: OS::Neutron::Net
- properties:
- name: { get_param: private_net_name }
- private_subnet:
- type: OS::Neutron::Subnet
- properties:
- network_id: { get_resource: private_net }
- cidr: { get_param: private_net_cidr }
- gateway_ip: { get_param: private_net_gateway }
- dns_nameservers: [ "8.8.8.8" ]
- # --------------- Router -------------------------------
- router:
- type: OS::Neutron::Router
- properties:
- 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 }
- # ----------- Wordpress ----------------------------
- wordpress_port:
- type: OS::Neutron::Port
- properties:
- network_id: { get_resource: private_net }
- fixed_ips:
- - subnet_id: { get_resource: private_subnet }
- wordpress_instance:
- type: OS::Nova::Server
- properties:
- image: { get_param: image_id }
- flavor: { get_param: instance_type }
- key_name: { get_param: key_name }
- networks:
- - port: { get_resource: wordpress_port }
- # key_name: { get_resource: my_key }
- user_data:
- str_replace:
- template: |
- #!/bin/bash -v
- yum -y install mariadb mariadb-server httpd wordpress
- touch /var/log/mariadb/mariadb.log
- chown mysql.mysql /var/log/mariadb/mariadb.log
- systemctl start mariadb.service
- # Setup MySQL root password and create a user
- 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"
- IDENTIFIED BY "db_password";
- FLUSH PRIVILEGES;
- EXIT
- EOF
- sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf
- sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf
- 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
- systemctl start httpd.service
- params:
- db_rootpassword: { get_param: db_root_password }
- db_name: { get_param: db_name }
- db_user: { get_param: db_username }
- db_password: { get_param: db_password }
- floating_ip:
- type: OS::Neutron::FloatingIP
- properties:
- floating_network: { get_param: public_net }
- floating_ip_assoc:
- type: OS::Neutron::FloatingIPAssociation
- properties:
- floatingip_id: { get_resource: floating_ip }
- port_id: { get_resource: wordpress_port }
- #---------------- Security Group --------------------
- security_group:
- type: OS::Neutron::SecurityGroup
- properties:
- name: mySecurityGroup
- description: Security Group for the Lab
- rules:
- - remote_ip_prefix: 0.0.0.0/0
- protocol: tcp
- port_range_min: 22
- port_range_max: 22
- - remote_ip_prefix: 0.0.0.0/0
- protocol: icmp
- - 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
- outputs:
- ip:
- description: The floating IP address assigned to the server.
- value: { get_attr: [floating_ip, floating_ip_address] }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement