From 0f075e0461220581213247f5216263a2cf1dc13a Mon Sep 17 00:00:00 2001 From: Mike Spreitzer Date: Fri, 18 Apr 2014 07:02:44 +0000 Subject: [PATCH] Worked on Fedora 20 examples in HOT Fixed the image names in hot/F20/WordPress_Native.yaml to match what DevStack will do with date-independent configuration. Adapted the 2-instance WordPress example. Turned off SELinux where it hurts. Change-Id: I373700de873e6e375622ab65bd4a175af96d217f Partial-Bug: #1305425 --- cfn/F17/WordPress_2_Instances.template | 1 + .../WordPress_2_Instances_With_EBS.template | 1 + ...ordPress_2_Instances_With_EBS_EIP.template | 1 + hot/F20/WordPress_2_Instances.yaml | 149 ++++++++++++++++++ hot/F20/WordPress_Native.yaml | 13 +- 5 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 hot/F20/WordPress_2_Instances.yaml diff --git a/cfn/F17/WordPress_2_Instances.template b/cfn/F17/WordPress_2_Instances.template index 5be32d08..1c164370 100644 --- a/cfn/F17/WordPress_2_Instances.template +++ b/cfn/F17/WordPress_2_Instances.template @@ -158,6 +158,7 @@ "sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n", "sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n", "sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseServer", "PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n", + "setenforce 0 # to allow net traffic with DB\n", "systemctl restart httpd.service\n" ]]}} } diff --git a/cfn/F17/WordPress_2_Instances_With_EBS.template b/cfn/F17/WordPress_2_Instances_With_EBS.template index 56a4917e..5ce8cfa1 100644 --- a/cfn/F17/WordPress_2_Instances_With_EBS.template +++ b/cfn/F17/WordPress_2_Instances_With_EBS.template @@ -192,6 +192,7 @@ "sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n", "sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n", "sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n", + "setenforce 0 # to allow net traffic with DB\n", "systemctl restart httpd.service\n" ]]}} } diff --git a/cfn/F17/WordPress_2_Instances_With_EBS_EIP.template b/cfn/F17/WordPress_2_Instances_With_EBS_EIP.template index 7b547a32..95234c30 100644 --- a/cfn/F17/WordPress_2_Instances_With_EBS_EIP.template +++ b/cfn/F17/WordPress_2_Instances_With_EBS_EIP.template @@ -228,6 +228,7 @@ "sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n", "sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n", "sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Ref" : "DatabaseIPAddress" }, "/ /usr/share/wordpress/wp-config.php\n", + "setenforce 0 # to allow net traffic with DB\n", "systemctl restart httpd.service\n" ]]}} } diff --git a/hot/F20/WordPress_2_Instances.yaml b/hot/F20/WordPress_2_Instances.yaml new file mode 100644 index 00000000..122ca6c0 --- /dev/null +++ b/hot/F20/WordPress_2_Instances.yaml @@ -0,0 +1,149 @@ +heat_template_version: 2013-05-23 + +description: > + An example Heat Orchestration Template (HOT). + WordPress is web software you can use to create a beautiful website + or blog. This template installs two instances: one running a + WordPress deployment and the other using a local MySQL database to + store the data. + +parameters: + + key_name: + type: string + description : Name of a KeyPair to enable SSH access to the instance + default: test_key + + instance_type: + type: string + description: Instance type for web and DB servers + default: m1.small + constraints: + - allowed_values: [m1.tiny, m1.small, m1.medium, m1.large, m1.xlarge] + description: instance_type must be a valid instance type + + image_id: + type: string + description: > + Name or ID of the image to use for the WordPress server. + Recommended values are fedora-20.i386 or fedora-20.x86_64; + get them from http://cloud.fedoraproject.org/fedora-20.i386.qcow2 + or http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2 . + default: fedora-20.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: admin + hidden: true + constraints: + - length: { min: 1, max: 16 } + description: db_username must be between 1 and 64 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: admin + hidden: true + constraints: + - length: { min: 1, max: 41 } + description: db_username must be between 1 and 64 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: admin + hidden: true + constraints: + - length: { min: 1, max: 41 } + description: db_username must be between 1 and 64 characters + - allowed_pattern: '[a-zA-Z0-9]*' + description: db_password must contain only alphanumeric characters + + +resources: + DatabaseServer: + type: OS::Nova::Server + properties: + image: { get_param: image_id } + flavor: { get_param: instance_type } + key_name: { get_param: key_name } + user_data: + str_replace: + template: | + #!/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 + 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 } + + WebServer: + type: OS::Nova::Server + properties: + image: { get_param: image_id } + flavor: { get_param: instance_type } + key_name: { get_param: key_name } + user_data: + str_replace: + template: | + #!/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 + 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 } + db_ipaddr: { get_attr: [DatabaseServer, networks, private, 0] } + +outputs: + WebsiteURL: + description: URL for Wordpress wiki + value: + str_replace: + template: http://host/wordpress + params: + host: { get_attr: [WebServer, networks, private, 0] } diff --git a/hot/F20/WordPress_Native.yaml b/hot/F20/WordPress_Native.yaml index e178f4e5..bf46b16d 100644 --- a/hot/F20/WordPress_Native.yaml +++ b/hot/F20/WordPress_Native.yaml @@ -21,12 +21,13 @@ parameters: description: instance_type must be one of m1.small, m1.medium or m1.large image_id: type: string - description: ID of the image to use for the WordPress server - default: Fedora-x86_64-20-20131211.1-sda - constraints: - - allowed_values: [ Fedora-i386-20-20131211.1-sda, Fedora-x86_64-20-20131211.1-sda ] - description: > - Image ID must be either Fedora-i386-20-20131211.1-sda or Fedora-x86_64-20-20131211.1-sda + description: > + Name or ID of the image to use for the WordPress server. + Recommended values are fedora-20.i386 or fedora-20.x86_64; + get them from http://cloud.fedoraproject.org/fedora-20.i386.qcow2 + or http://cloud.fedoraproject.org/fedora-20.x86_64.qcow2 . + default: fedora-20.x86_64 + db_name: type: string description: WordPress database name