Last active
January 18, 2019 04:34
-
-
Save sofyan48/7c296cd10147297d60858a10c7656a08 to your computer and use it in GitHub Desktop.
WORDPRESS HEAT TEMPLATE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -v | |
| yum -y install mariadb mariadb-server | |
| 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'@'%' | |
| IDENTIFIED BY '$db_password'; | |
| FLUSH PRIVILEGES; | |
| EXIT | |
| EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| heat_template_version: 2016-10-14 | |
| description: Template Create Wordpress | |
| parameters: | |
| key_name: | |
| type: string | |
| description: Name of a key pair to enable SSH access to instances. | |
| flavor: | |
| type: string | |
| description: Flavor to use for the WordPress server. | |
| image: | |
| type: string | |
| description: Image From Wordpress | |
| default: Fedora 26 | |
| db_name: | |
| type: string | |
| description: WordPress database name | |
| default: wordpress | |
| db_username: | |
| type: string | |
| description: The WordPress database admin account username | |
| default: admin | |
| private_network: | |
| type: string | |
| label: Private Network | |
| description: Setup Private network | |
| username: | |
| type: string | |
| label: Set Username | |
| description: Set username to virtual machine. | |
| public_network: | |
| type: string | |
| label: Public network name or ID | |
| description: Public network to attach server to. | |
| default: Public_Network | |
| resources: | |
| wordpress_config: | |
| type: OS::Heat::SoftwareConfig | |
| properties: | |
| inputs: | |
| - name: db_name | |
| - name: db_user | |
| - name: db_password | |
| - name: db_ipaddr | |
| group: script | |
| config: { get_file: wp_install.sh } | |
| secgroup: | |
| type: OS::Neutron::SecurityGroup | |
| properties: | |
| name: | |
| list_join: [-, [{ get_param: 'OS::stack_name' },neo,secgroup]] | |
| rules: | |
| - protocol: icmp | |
| - protocol: udp | |
| - protocol: tcp | |
| port_range_min: 22 | |
| port_range_max: 22 | |
| - protocol: tcp | |
| port_range_min: 443 | |
| port_range_max: 443 | |
| - protocol: tcp | |
| port_range_min: 80 | |
| port_range_max: 80 | |
| - remote_mode: remote_group_id | |
| define_port: | |
| type: OS::Neutron::Port | |
| properties: | |
| admin_state_up: true | |
| network_id: { get_param: private_network } | |
| security_groups: | |
| - {get_resource: secgroup} | |
| floating: | |
| type: OS::Neutron::FloatingIP | |
| properties: | |
| floating_network: {get_param: public_network} | |
| port_id: {get_resource: define_port} | |
| cloud_config: | |
| type: OS::Heat::MultipartMime | |
| properties: | |
| parts: | |
| - config: | |
| str_replace: | |
| params: | |
| $USERNAME : { get_param: username } | |
| template: | | |
| #cloud-config | |
| system_info: | |
| default_user: | |
| name: $USERNAME | |
| lock_passwd: true | |
| gecos: Instances Interactive User | |
| groups: [wheel, adm, systemd-journal] | |
| sudo: ["ALL=(ALL) NOPASSWD:ALL"] | |
| shell: /bin/bash | |
| db_config: | |
| type: OS::Heat::SoftwareConfig | |
| properties: | |
| inputs: | |
| - name: db_rootpassword | |
| - name: db_name | |
| - name: db_user | |
| - name: db_password | |
| group: script | |
| config: { get_file: db_install.sh } | |
| db_root_password: | |
| type: OS::Heat::RandomString | |
| db_password: | |
| type: OS::Heat::RandomString | |
| wordpress_deployment: | |
| type: OS::Heat::SoftwareDeployment | |
| depends_on: db_deployment | |
| properties: | |
| config: | |
| get_resource: wordpress_config | |
| server: | |
| get_resource: wordpress_instance | |
| input_values: | |
| db_name: { get_param: db_name } | |
| db_user: { get_param: db_username } | |
| db_password: { get_attr: [ db_password, value ] } | |
| db_ipaddr: { get_attr: [ wordpress_instance, networks, private, 0 ] } | |
| db_deployment: | |
| type: OS::Heat::SoftwareDeployment | |
| properties: | |
| config: | |
| get_resource: db_config | |
| server: | |
| get_resource: wordpress_instance | |
| input_values: | |
| db_rootpassword: { get_attr: [ db_root_password, value ] } | |
| db_name: { get_param: db_name } | |
| db_user: { get_param: db_username } | |
| db_password: { get_attr: [ db_password, value ] } | |
| wordpress_instance: | |
| type: OS::Nova::Server | |
| properties: | |
| name: { get_param: 'OS::stack_name' } | |
| image: { get_param: image } | |
| flavor: { get_param: flavor } | |
| key_name: { get_param: key_name } | |
| networks: | |
| - port: {get_resource: define_port} | |
| user_data_format: RAW | |
| user_data: {get_resource: cloud_config} | |
| outputs: | |
| user: | |
| description: User Name | |
| value: {get_param: username} | |
| controller: | |
| description: Controller IP | |
| value: {get_attr: [floating,floating_ip_address]} | |
| key_name: | |
| description: Key Name | |
| value: {get_param: key_name} | |
| wordpress: | |
| description: wordpress folder | |
| value: /etc/wordpress |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -v | |
| yum -y install httpd wordpress | |
| 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 | |
| sed -i s/localhost/$db_ipaddr/ /etc/wordpress/wp-config.php | |
| setenforce 0 # Otherwise net traffic with DB is disabled | |
| systemctl start httpd.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment