Advertisement
Guest User

Untitled

a guest
May 5th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.55 KB | None | 0 0
  1. heat_template_version: 2013-05-23
  2.  
  3. parameters:
  4. #External Network
  5. public_net:
  6. type: string
  7. description: ID or name of public network for which floating IP addresses will be allocated
  8. default: ext-net
  9.  
  10. #Internal Network
  11. private_net_name:
  12. type: string
  13. description: Name of private network to be created
  14. default: myInternalNetwork
  15. #IP
  16. private_net_cidr:
  17. type: string
  18. description: Private network address (CIDR notation)
  19. default: 10.0.1.0/24
  20. private_net_gateway:
  21. type: string
  22. description: Private network gateway address
  23. default: 10.0.1.1
  24.  
  25. #URL: http://git.openstack.org/cgit/openstack/heat-templates/plain/hot/F20/WordPress_Native.yaml
  26. #WordPress
  27. key_name:
  28. type: string
  29. description: Name of a KeyPair to enable SSH access to the instance
  30. default: superkey
  31. instance_type:
  32. type: string
  33. description: Instance type for WordPress server
  34. default: m1.small
  35. image_id:
  36. type: string
  37. description: >
  38. Name or ID of the image to use for the WordPress server.
  39. default: fedora-21.x86_64
  40.  
  41.  
  42. db_name:
  43. type: string
  44. description: WordPress database name
  45. default: wordpress
  46. constraints:
  47. - length: { min: 1, max: 64 }
  48. description: db_name must be between 1 and 64 characters
  49. - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*'
  50. description: >
  51. db_name must begin with a letter and contain only alphanumeric
  52. characters
  53. db_username:
  54. type: string
  55. description: The WordPress database admin account username
  56. default: lab4
  57. constraints:
  58. - length: { min: 1, max: 16 }
  59. description: db_username must be between 1 and 16 characters
  60. - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*'
  61. description: >
  62. db_username must begin with a letter and contain only alphanumeric
  63. characters
  64. db_password:
  65. type: string
  66. description: The WordPress database admin account password
  67. default: lab4
  68. constraints:
  69. - length: { min: 1, max: 41 }
  70. description: db_password must be between 1 and 41 characters
  71. - allowed_pattern: '[a-zA-Z0-9]*'
  72. description: db_password must contain only alphanumeric characters
  73. db_root_password:
  74. type: string
  75. description: Root password for MySQL
  76. default: lab4
  77. constraints:
  78. - length: { min: 1, max: 41 }
  79. description: db_root_password must be between 1 and 41 characters
  80. - allowed_pattern: '[a-zA-Z0-9]*'
  81. description: db_root_password must contain only alphanumeric characters
  82.  
  83. resources:
  84.  
  85. # -------------- Creating Key --------------------------
  86. my_key:
  87. type: OS::Nova::KeyPair
  88. properties:
  89. name: my_Key
  90. save_private_key: true
  91.  
  92. # -------------- Internal Network -----------------------
  93. private_net:
  94. type: OS::Neutron::Net
  95. properties:
  96. name: { get_param: private_net_name }
  97.  
  98. private_subnet:
  99. type: OS::Neutron::Subnet
  100. properties:
  101. network_id: { get_resource: private_net }
  102. cidr: { get_param: private_net_cidr }
  103. gateway_ip: { get_param: private_net_gateway }
  104. dns_nameservers: [ "8.8.8.8" ]
  105.  
  106. # --------------- Router -------------------------------
  107.  
  108. router:
  109. type: OS::Neutron::Router
  110. properties:
  111. external_gateway_info:
  112. network: { get_param: public_net }
  113.  
  114. router_interface:
  115. type: OS::Neutron::RouterInterface
  116. properties:
  117. router_id: { get_resource: router }
  118. subnet_id: { get_resource: private_subnet }
  119.  
  120. # ----------- Wordpress ----------------------------
  121.  
  122. wordpress_port:
  123. type: OS::Neutron::Port
  124. properties:
  125. network_id: { get_resource: private_net }
  126. fixed_ips:
  127. - subnet_id: { get_resource: private_subnet }
  128.  
  129. wordpress_instance:
  130. type: OS::Nova::Server
  131. properties:
  132. image: { get_param: image_id }
  133. flavor: { get_param: instance_type }
  134. key_name: { get_param: key_name }
  135. networks:
  136. - port: { get_resource: wordpress_port }
  137. # key_name: { get_resource: my_key }
  138.  
  139. user_data:
  140. str_replace:
  141. template: |
  142. #!/bin/bash -v
  143.  
  144. yum -y install mariadb mariadb-server httpd wordpress
  145. touch /var/log/mariadb/mariadb.log
  146. chown mysql.mysql /var/log/mariadb/mariadb.log
  147. systemctl start mariadb.service
  148.  
  149. # Setup MySQL root password and create a user
  150. mysqladmin -u root password db_rootpassword
  151. cat << EOF | mysql -u root --password=db_rootpassword
  152. CREATE DATABASE db_name;
  153. GRANT ALL PRIVILEGES ON db_name.* TO "db_user"@"localhost"
  154. IDENTIFIED BY "db_password";
  155. FLUSH PRIVILEGES;
  156. EXIT
  157. EOF
  158.  
  159. sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf
  160. sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf
  161. sed -i s/database_name_here/db_name/ /etc/wordpress/wp-config.php
  162. sed -i s/username_here/db_user/ /etc/wordpress/wp-config.php
  163. sed -i s/password_here/db_password/ /etc/wordpress/wp-config.php
  164.  
  165. systemctl start httpd.service
  166. params:
  167. db_rootpassword: { get_param: db_root_password }
  168. db_name: { get_param: db_name }
  169. db_user: { get_param: db_username }
  170. db_password: { get_param: db_password }
  171.  
  172.  
  173.  
  174. floating_ip:
  175. type: OS::Neutron::FloatingIP
  176. properties:
  177. floating_network: { get_param: public_net }
  178.  
  179. floating_ip_assoc:
  180. type: OS::Neutron::FloatingIPAssociation
  181. properties:
  182. floatingip_id: { get_resource: floating_ip }
  183. port_id: { get_resource: wordpress_port }
  184.  
  185. #---------------- Security Group --------------------
  186. security_group:
  187. type: OS::Neutron::SecurityGroup
  188. properties:
  189. name: mySecurityGroup
  190. description: Security Group for the Lab
  191. rules:
  192. - remote_ip_prefix: 0.0.0.0/0
  193. protocol: tcp
  194. port_range_min: 22
  195. port_range_max: 22
  196. - remote_ip_prefix: 0.0.0.0/0
  197. protocol: icmp
  198. - remote_ip_prefix: 0.0.0.0/0
  199. protocol: tcp
  200. port_range_min: 80
  201. port_range_max: 80
  202. - remote_ip_prefix: 0.0.0.0/0
  203. protocol: tcp
  204. port_range_min: 443
  205. port_range_max: 443
  206.  
  207. outputs:
  208. ip:
  209. description: The floating IP address assigned to the server.
  210. value: { get_attr: [floating_ip, floating_ip_address] }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement