From: Steven Dake Date: Mon, 16 Apr 2012 00:44:10 +0000 (-0700) Subject: Make Wordpress_2_Instances.template work properly X-Git-Tag: 2014.1~2004 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=67c6131536ca102eec6ad69a73fca874fd8cc2ad;p=openstack-build%2Fheat-build.git Make Wordpress_2_Instances.template work properly note the mysql instance is not secure because both IPs must be known ahead of time. To resolve this problem, we will be using elastic IPs. Signed-off-by: Steven Dake --- diff --git a/templates/WordPress_2_Instances.template b/templates/WordPress_2_Instances.template index 4add0393..263296ba 100644 --- a/templates/WordPress_2_Instances.template +++ b/templates/WordPress_2_Instances.template @@ -92,22 +92,20 @@ }, "Resources" : { - - "WebServer": { + "DatabaseServer": { "Type": "AWS::EC2::Instance", - "DependsOn": "DatabaseServer", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "packages" : { "yum" : { - "httpd" : [], - "wordpress" : [] + "mysql" : [], + "mysql-server" : [] } }, "services" : { "systemd" : { - "httpd" : { "enabled" : "true", "ensureRunning" : "true" } + "mysqld" : { "enabled" : "true", "ensureRunning" : "true" } } } } @@ -121,27 +119,35 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init -f /var/lib/cloud/data/cfn-init-data\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/DB_HOST/", "/ /usr/share/wordpress/wp-config.php\n", - "set --in-place --e \"s/DB_HOST\\s*',\\s*'localhost/DB_HOST', '", { "Fn::GetAtt": ["DatabaseServer", "PrivateIp"] }, "/\" /usr/share/wordpress/wp-config.php\n", - "cp /usr/share/wordpress/wp-config.php /usr/share/wordpress/wp-config.orig\n" + "# Setup MySQL root password and create a user\n", + "mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n", + "cat >> /tmp/mysql-wordpress-config << EOF\n", + "CREATE DATABASE ", { "Ref" : "DBName" }, ";\n", + "GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"%\"\n", + "IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n", + "FLUSH PRIVILEGES;\n", + "EXIT\n", + "EOF\n", + "cat /tmp/mysql-wordpress-config | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/mysql-wordpress-config\n" ]]}} } }, - "DatabaseServer": { + "WebServer": { "Type": "AWS::EC2::Instance", + "DependsOn": "DatabaseServer", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "packages" : { "yum" : { - "mysql" : [], - "mysql-server" : [] + "httpd" : [], + "wordpress" : [] } }, "services" : { "systemd" : { - "mysqld" : { "enabled" : "true", "ensureRunning" : "true" } + "httpd" : { "enabled" : "true", "ensureRunning" : "true" } } } } @@ -155,21 +161,11 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init -f /var/lib/cloud/data/cfn-init-data\n", - "# Setup MySQL root password and create a user\n", - "mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n", - "cat >> /tmp/mysql-wordpress-config << EOF\n", - "CREATE DATABASE ", { "Ref" : "DBName" }, ";\n", - "GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n", - "IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n", - "FLUSH PRIVILEGES;\n", - "EXIT\n", - "EOF\n", - "cat /tmp/mysql-wordpress-config | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/mysql-wordpress-config\n", - "sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n", - "cp /usr/share/wordpress/wp-config.php /usr/share/wordpress/wp-config.orig\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" ]]}} } } + }, "Outputs" : {