Advertisement
Guest User

wordpress

a guest
Nov 4th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. heat_template_version: 2013-05-23
  2.  
  3. description: Template that installs a wordpress server.
  4.  
  5. parameters:
  6. image:
  7. type: string
  8. label: Image name or ID
  9. description: Image to be used for server. Please use an Ubuntu based image.
  10. flavor:
  11. type: string
  12. label: Flavor
  13. description: Type of instance (flavor) to be used on the compute instance.
  14. key:
  15. type: string
  16. label: Key name
  17. description: Name of key-pair to be installed on the compute instance.
  18. private_network:
  19. type: string
  20. label: Private network name or ID
  21. description: Network to attach server to.
  22. mysql_server:
  23. type: string
  24. label: MySQL database server
  25. description: IP address of the MySQL database server.
  26. database_name:
  27. type: string
  28. label: Database name
  29. description: Name of the application database.
  30. database_user:
  31. type: string
  32. label: Database user
  33. description: Name of the database user.
  34. database_password:
  35. type: string
  36. label: Database password
  37. hidden: true
  38. description: Password to access the database.
  39.  
  40. resources:
  41. wait_condition:
  42. type: OS::Heat::WaitCondition
  43. properties:
  44. handle: { get_resource: wh }
  45. count: 1
  46. timeout: 1200
  47.  
  48. wh:
  49. type: OS::Heat::WaitConditionHandle
  50.  
  51. security_group:
  52. type: OS::Neutron::SecurityGroup
  53. properties:
  54. name: web_server_security_group
  55. rules:
  56. - port_range_min: 80
  57. port_range_max: 80
  58. protocol: tcp
  59. direction: ingress
  60. - port_range_min: 80
  61. port_range_max: 80
  62. protocol: tcp
  63. direction: egress
  64.  
  65. port:
  66. type: OS::Neutron::Port
  67. properties:
  68. network: { get_param: private_network }
  69. security_groups:
  70. - { get_resource: security_group }
  71. - default
  72.  
  73. wordpress_instance:
  74. type: OS::Nova::Server
  75. properties:
  76. image: { get_param: image }
  77. flavor: { get_param: flavor }
  78. key_name: { get_param: key }
  79. networks:
  80. - port: { get_resource: port }
  81. user_data_format: RAW
  82. user_data:
  83. str_replace:
  84. params:
  85. __mysql_ip__: { get_param: mysql_server }
  86. __database_name__: { get_param: database_name }
  87. __database_user__: { get_param: database_user }
  88. __database_password__: { get_param: database_password }
  89. wc_notify: { get_attr: ['wh', 'curl_cli'] }
  90. template: |
  91. #!/bin/bash -ex
  92.  
  93. # install dependencies
  94. echo "deb-src http://172.24.4.1/debs/ amd64/" > /etc/apt/source.list
  95. apt-get update
  96. apt-get -y install apache2 php5 libapache2-mod-php5 php5-mysql php5-gd mysql-client
  97.  
  98. # download wordpress
  99. wget http://wordpress.org/latest.tar.gz
  100. tar -xzf latest.tar.gz
  101.  
  102. # configure wordpress
  103. cp wordpress/wp-config-sample.php wordpress/wp-config.php
  104. sed -i 's/database_name_here/__database_name__/' wordpress/wp-config.php
  105. sed -i 's/username_here/__database_user__/' wordpress/wp-config.php
  106. sed -i 's/password_here/__database_password__/' wordpress/wp-config.php
  107. sed -i 's/localhost/__mysql_ip__/' wordpress/wp-config.php
  108.  
  109. # install a copy of the configured wordpress into apache's www directory
  110. rm /var/www/html/index.html
  111. cp -R wordpress/* /var/www/html/
  112.  
  113. # give apache ownership of the application files
  114. chown -R www-data:www-data /var/www/html/
  115. chmod -R g+w /var/www/html/
  116.  
  117. # notify heat that we are done here
  118. wc_notify --data-binary '{"status": "SUCCESS"}'
  119.  
  120. outputs:
  121. name:
  122. description: Name of the wordpress instance.
  123. value: { get_attr: [wordpress_instance, name] }
  124. ip:
  125. description: The IP address of the wordpress instance.
  126. value: { get_attr: [wordpress_instance, first_address] }
  127. port:
  128. description: The network port of the wordpress instance.
  129. value: { get_resource: port }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement