Skip to content

Instantly share code, notes, and snippets.

@vuanhson
Created February 18, 2018 04:11
Show Gist options
  • Save vuanhson/d613eb4ae6e7979bacc98459ca9e16e9 to your computer and use it in GitHub Desktop.
Save vuanhson/d613eb4ae6e7979bacc98459ca9e16e9 to your computer and use it in GitHub Desktop.
Heat template Wordpress - Khai phím đầu năm :3
heat_template_version: 2017-09-01
description: |
study heat
multi-line description
parameters:
key_name:
type: string
label: Nhap key pair name
description: keypair
image:
type: string
label: Nhap image name
description: image
default: fedora-software-config
flavor:
type: string
label: nhap flavor
description: flavor
network:
type: string
label: Nhap network name
description: network
default: provider
db_name:
type: string
label: wordpress database name
default: wpdb
db_password:
type: string
label: password database
default: 23111995
hidden: true
resources:
wp_instance:
type: OS::Nova::Server
properties:
key_name: {get_param: key_name}
image: {get_param: image}
flavor: {get_param: flavor}
networks:
- network: {get_param: network}
user_data:
str_replace:
template: |
#!/bin/bash -v
dnf -y install httpd wordpress -q
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 # de vao httpd
systemctl start httpd.service
params:
$db_name: {get_param: db_name}
$db_user: "root"
$db_password: {get_param: db_password}
$db_ipaddr: {get_attr: [db_instance, first_address]}
db_instance:
type: OS::Nova::Server
properties:
key_name: {get_param: key_name}
image: {get_param: image}
flavor: {get_param: flavor}
networks:
- network: {get_param: network}
user_data:
str_replace:
template: |
#!/bin/bash -v
dnf -y install mariadb mariadb-server -q
touch /var/log/mariadb/mariadb.log
chown mysql.mysql /var/log/mariadb/mariadb.log
systemctl start mariadb.service
# tao DB
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
params:
$db_rootpassword: ""
$db_name: {get_param: db_name}
$db_password: {get_param: db_password}
$db_user: "root"
outputs:
db_instance_ip:
description: DB instance ip
value: {get_attr: [db_instance, first_address]}
wp_instance_ip:
description: wordpress instance ip
value: {get_attr: [wp_instance, first_address]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment