From 067323878522df12484c02211e852609185cb4fb Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Tue, 12 Feb 2013 16:02:44 +0000 Subject: [PATCH] heat templates : allow access to wordpress in example templates Latest wordpress package in Fedora defaults to deny-all so trying to access the wordpress site on the instance no longer works, so sed out the deny all to allow template examples and integration tests to work again Fixes bug 1123053 Change-Id: I7597e4f491426e639c4c19a92f610c8a693dc1f3 Signed-off-by: Steven Hardy --- templates/WordPress_2_Instances.template | 4 +- .../WordPress_2_Instances_With_EBS.template | 4 +- ...ordPress_2_Instances_With_EBS_EIP.template | 4 +- templates/WordPress_And_Http.template | 4 +- .../WordPress_Composed_Instances.template | 4 +- templates/WordPress_Single_Instance.template | 4 +- templates/WordPress_Single_Instance.yaml | 79 ++++++++++++------- ...ordPress_Single_Instance_With_EBS.template | 1 + ...ress_Single_Instance_With_EBS_EIP.template | 1 + ...ordPress_Single_Instance_With_EIP.template | 4 +- ...WordPress_Single_Instance_With_HA.template | 3 + ...gle_Instance_With_HA_AccessPolicy.template | 3 + ...ordPress_Single_Instance_With_IHA.template | 3 + ...ress_Single_Instance_With_Quantum.template | 4 +- .../WordPress_Single_Instance_gold.template | 1 + templates/WordPress_With_LB.template | 4 +- templates/WordPress_With_RDS.template | 4 +- 17 files changed, 93 insertions(+), 38 deletions(-) diff --git a/templates/WordPress_2_Instances.template b/templates/WordPress_2_Instances.template index 6ec34dce..11283dfd 100644 --- a/templates/WordPress_2_Instances.template +++ b/templates/WordPress_2_Instances.template @@ -160,7 +160,9 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\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" + "sed -i \"/Deny from All/d\" /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", + "systemctl restart httpd.service\n" ]]}} } } diff --git a/templates/WordPress_2_Instances_With_EBS.template b/templates/WordPress_2_Instances_With_EBS.template index 3a7259d5..8eafe077 100644 --- a/templates/WordPress_2_Instances_With_EBS.template +++ b/templates/WordPress_2_Instances_With_EBS.template @@ -194,7 +194,9 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\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" + "sed -i \"/Deny from All/d\" /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", + "systemctl restart httpd.service\n" ]]}} } }, diff --git a/templates/WordPress_2_Instances_With_EBS_EIP.template b/templates/WordPress_2_Instances_With_EBS_EIP.template index a7fac58a..7807cf14 100644 --- a/templates/WordPress_2_Instances_With_EBS_EIP.template +++ b/templates/WordPress_2_Instances_With_EBS_EIP.template @@ -230,7 +230,9 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\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" + "sed -i \"/Deny from All/d\" /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", + "systemctl restart httpd.service\n" ]]}} } }, diff --git a/templates/WordPress_And_Http.template b/templates/WordPress_And_Http.template index 77e853e4..81946912 100644 --- a/templates/WordPress_And_Http.template +++ b/templates/WordPress_And_Http.template @@ -116,11 +116,13 @@ "UserData" : { "Fn::Base64": { "Fn::Join": ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\n", + "sed -i \"/Deny from All/d\" /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": "DBIpaddress"}, - "/ /usr/share/wordpress/wp-config.php\n" + "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } } diff --git a/templates/WordPress_Composed_Instances.template b/templates/WordPress_Composed_Instances.template index a29af242..77ceeba5 100644 --- a/templates/WordPress_Composed_Instances.template +++ b/templates/WordPress_Composed_Instances.template @@ -136,7 +136,9 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\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" : [ "DatabaseTemplate", "Outputs.PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n" + "sed -i \"/Deny from All/d\" /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" : [ "DatabaseTemplate", "Outputs.PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } } diff --git a/templates/WordPress_Single_Instance.template b/templates/WordPress_Single_Instance.template index c44377a7..07d398b9 100644 --- a/templates/WordPress_Single_Instance.template +++ b/templates/WordPress_Single_Instance.template @@ -131,7 +131,9 @@ "FLUSH PRIVILEGES;\n", "EXIT\n", "EOF\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" + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } } diff --git a/templates/WordPress_Single_Instance.yaml b/templates/WordPress_Single_Instance.yaml index 48322f80..db813f29 100644 --- a/templates/WordPress_Single_Instance.yaml +++ b/templates/WordPress_Single_Instance.yaml @@ -4,9 +4,8 @@ Description: 'AWS CloudFormation Sample Template WordPress_Single_Instance: template installs a single-instance WordPress deployment using a local MySQL database to store the data.' Parameters: - KeyName: - Description: Name of an existing EC2 KeyPair to enable SSH access to the instances - Type: String + KeyName: {Description: Name of an existing EC2 KeyPair + to enable SSH access to the instances, Type: String} InstanceType: Description: WebServer EC2 instance type Type: String @@ -87,43 +86,66 @@ Resources: Fn::Base64: Fn::Join: - '' - - - |- - #!/bin/bash -v - /opt/aws/bin/cfn-init - # Setup MySQL root password and create a user - mysqladmin -u root password ' + - - '#!/bin/bash -v + + ' + - '/opt/aws/bin/cfn-init + + ' + - '# Setup MySQL root password and create a user + + ' + - mysqladmin -u root password ' - {Ref: DBRootPassword} - - |- - ' - cat << EOF | mysql -u root --password=' + - ''' + + ' + - cat << EOF | mysql -u root --password=' - {Ref: DBRootPassword} - - |- - ' - CREATE DATABASE + - ''' + + ' + - 'CREATE DATABASE ' - {Ref: DBName} - - |- - ; - GRANT ALL PRIVILEGES ON + - '; + + ' + - 'GRANT ALL PRIVILEGES ON ' - {Ref: DBName} - .* TO " - {Ref: DBUsername} - - |- - "@"localhost" - IDENTIFIED BY " + - '"@"localhost" + + ' + - IDENTIFIED BY " - {Ref: DBPassword} - - |- - "; - FLUSH PRIVILEGES; - EXIT - EOF - sed --in-place --e s/database_name_here/ + - '"; + + ' + - 'FLUSH PRIVILEGES; + + ' + - 'EXIT + + ' + - 'EOF + + ' + - 'sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf + + ' + - 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 + - '/ /usr/share/wordpress/wp-config.php + + ' + - 'systemctl restart httpd.service + + ' Outputs: WebsiteURL: Value: @@ -133,3 +155,4 @@ Outputs: - Fn::GetAtt: [WikiDatabase, PublicIp] - /wordpress Description: URL for Wordpress wiki + diff --git a/templates/WordPress_Single_Instance_With_EBS.template b/templates/WordPress_Single_Instance_With_EBS.template index fbf35729..005a2955 100644 --- a/templates/WordPress_Single_Instance_With_EBS.template +++ b/templates/WordPress_Single_Instance_With_EBS.template @@ -156,6 +156,7 @@ "FLUSH PRIVILEGES;\n", "EXIT\n", "EOF\n", + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", "systemctl restart httpd.service\n" ]]}} diff --git a/templates/WordPress_Single_Instance_With_EBS_EIP.template b/templates/WordPress_Single_Instance_With_EBS_EIP.template index 6d38cc2d..84dd984a 100644 --- a/templates/WordPress_Single_Instance_With_EBS_EIP.template +++ b/templates/WordPress_Single_Instance_With_EBS_EIP.template @@ -180,6 +180,7 @@ "FLUSH PRIVILEGES;\n", "EXIT\n", "EOF\n", + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", "systemctl restart httpd.service\n" ]]}} diff --git a/templates/WordPress_Single_Instance_With_EIP.template b/templates/WordPress_Single_Instance_With_EIP.template index f65220db..cb55116d 100644 --- a/templates/WordPress_Single_Instance_With_EIP.template +++ b/templates/WordPress_Single_Instance_With_EIP.template @@ -156,7 +156,9 @@ "FLUSH PRIVILEGES;\n", "EXIT\n", "EOF\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" + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } } diff --git a/templates/WordPress_Single_Instance_With_HA.template b/templates/WordPress_Single_Instance_With_HA.template index 5db88ca2..e4a45c25 100644 --- a/templates/WordPress_Single_Instance_With_HA.template +++ b/templates/WordPress_Single_Instance_With_HA.template @@ -253,11 +253,14 @@ "mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n", + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n", + "# install cfn-hup crontab\n", "crontab /tmp/cfn-hup-crontab.txt\n", diff --git a/templates/WordPress_Single_Instance_With_HA_AccessPolicy.template b/templates/WordPress_Single_Instance_With_HA_AccessPolicy.template index 082d9984..fcc74e06 100644 --- a/templates/WordPress_Single_Instance_With_HA_AccessPolicy.template +++ b/templates/WordPress_Single_Instance_With_HA_AccessPolicy.template @@ -262,11 +262,14 @@ "mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n", + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n", + "# install cfn-hup crontab\n", "crontab /tmp/cfn-hup-crontab.txt\n", diff --git a/templates/WordPress_Single_Instance_With_IHA.template b/templates/WordPress_Single_Instance_With_IHA.template index 9b7d958a..f99586c1 100644 --- a/templates/WordPress_Single_Instance_With_IHA.template +++ b/templates/WordPress_Single_Instance_With_IHA.template @@ -228,11 +228,14 @@ "mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n", + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n", + "# install cfn-hup crontab\n", "crontab /tmp/cfn-hup-crontab.txt\n", diff --git a/templates/WordPress_Single_Instance_With_Quantum.template b/templates/WordPress_Single_Instance_With_Quantum.template index f466e4a3..1712cdc9 100644 --- a/templates/WordPress_Single_Instance_With_Quantum.template +++ b/templates/WordPress_Single_Instance_With_Quantum.template @@ -171,7 +171,9 @@ "FLUSH PRIVILEGES;\n", "EXIT\n", "EOF\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" + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } } diff --git a/templates/WordPress_Single_Instance_gold.template b/templates/WordPress_Single_Instance_gold.template index 621e8a33..520b9fd1 100644 --- a/templates/WordPress_Single_Instance_gold.template +++ b/templates/WordPress_Single_Instance_gold.template @@ -132,6 +132,7 @@ "EXIT\n", "EOF\n", "cat /tmp/mysql-wordpress-config | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/mysql-wordpress-config\n", + "sed -i \"/Deny from All/d\" /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" }, "/ /usr/share/wordpress/wp-config.php\n", "cp /usr/share/wordpress/wp-config.php /usr/share/wordpress/wp-config.orig\n" ]]}} diff --git a/templates/WordPress_With_LB.template b/templates/WordPress_With_LB.template index 9e25a5f9..42d5ef70 100644 --- a/templates/WordPress_With_LB.template +++ b/templates/WordPress_With_LB.template @@ -136,11 +136,13 @@ "UserData" : { "Fn::Base64": { "Fn::Join": ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\n", + "sed -i \"/Deny from All/d\" /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", "Outputs.PublicIp" ]}, - "/ /usr/share/wordpress/wp-config.php\n" + "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } }, diff --git a/templates/WordPress_With_RDS.template b/templates/WordPress_With_RDS.template index bbf51357..f616d854 100644 --- a/templates/WordPress_With_RDS.template +++ b/templates/WordPress_With_RDS.template @@ -151,7 +151,9 @@ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "#!/bin/bash -v\n", "/opt/aws/bin/cfn-init\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", "Endpoint.Address" ]}, "/ /usr/share/wordpress/wp-config.php\n" + "sed -i \"/Deny from All/d\" /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", "Endpoint.Address" ]}, "/ /usr/share/wordpress/wp-config.php\n", + "systemctl restart httpd.service\n" ]]}} } } -- 2.45.2