]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Make Wordpress_2_Instances.template work properly
authorSteven Dake <sdake@redhat.com>
Mon, 16 Apr 2012 00:44:10 +0000 (17:44 -0700)
committerSteven Dake <sdake@redhat.com>
Mon, 16 Apr 2012 00:45:09 +0000 (17:45 -0700)
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 <sdake@redhat.com>
templates/WordPress_2_Instances.template

index 4add0393d19d88ef0070e102ebeee6dc4ea7317b..263296ba76acc11f45a5b05fe139c3c9ed6118ed 100644 (file)
   },
 
   "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" }
               }
             }
           }
         "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" }
               }
             }
           }
         "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" : {