-
-
Save jeevanullas/87524e26527c81957aae to your computer and use it in GitHub Desktop.
cfn-get-metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWS::CloudFormation::Init": { | |
"install_wordpress": { | |
"files": { | |
"/tmp/setup.mysql": { | |
"content": "CREATE DATABASE wordpressdb;\nCREATE USER 'deependra'@'localhost' IDENTIFIED BY 'password';\nGRANT ALL ON wordpressdb.* TO 'deependra'@'localhost';\nFLUSH PRIVILEGES;\n", | |
"owner": "root", | |
"group": "root", | |
"mode": "000400" | |
}, | |
"/tmp/create-wp-config": { | |
"content": "#!/bin/bash -xe\ncp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php\nsed -i \"s/'database_name_here'/'wordpressdb'/g\" wp-config.php\nsed -i \"s/'username_here'/'deependra'/g\" wp-config.php\nsed -i \"s/'password_here'/'password'/g\" wp-config.php\n", | |
"owner": "root", | |
"group": "root", | |
"mode": "000500" | |
} | |
}, | |
"sources": { | |
"/var/www/html": "http://jeevanullas.in/tmp/latest.tar.gz" | |
}, | |
"packages": { | |
"yum": { | |
"mysql-devel": [], | |
"httpd": [], | |
"mysql-server": [], | |
"mysql-libs": [], | |
"php-mysql": [], | |
"mysql": [], | |
"php": [] | |
} | |
}, | |
"services": { | |
"sysvinit": { | |
"httpd": { | |
"ensureRunning": "true", | |
"enabled": "true" | |
}, | |
"mysqld": { | |
"ensureRunning": "true", | |
"enabled": "true" | |
} | |
} | |
} | |
}, | |
"configure_wordpress": { | |
"commands": { | |
"03_configure_wordpress": { | |
"command": "/tmp/create-wp-config", | |
"cwd": "/var/www/html/wordpress" | |
}, | |
"02_create_database": { | |
"test": "$(mysql wordpressdb -u root --password='mypassword' >/dev/null 2>&1 </dev/null); (( $? != 0 ))", | |
"command": "mysql -u root --password='mypassword' < /tmp/setup.mysql" | |
}, | |
"01_set_mysql_root_password": { | |
"test": "$(mysql wordpressdb -u root --password='mypassword' >/dev/null 2>&1 </dev/null); (( $? != 0 ))", | |
"command": "mysqladmin -u root password 'mypassword'" | |
} | |
} | |
}, | |
"install_cfn": { | |
"files": { | |
"/etc/cfn/cfn-hup.conf": { | |
"content": "[main]\nstack=arn:aws:cloudformation:eucalyptus:772503674779:stack/Wordpress/897b46f2-030b-4a4d-afd7-0a0a6a3f5fa6\nurl=https://cloudformation.cloud.jeevanullas.in\nrole=adminrole\nregion=eucalyptus\n", | |
"owner": "root", | |
"group": "root", | |
"mode": "000400" | |
}, | |
"/etc/cfn/hooks.d/cfn-auto-reloader.conf": { | |
"content": "[cfn-auto-reloader-hook]\ntriggers=post.update\npath=Resources.WebServer.Metadata.AWS::CloudFormation::Init\naction=/opt/aws/bin/cfn-init -v --stack Wordpress --resource WebServer --urlhttps://cloudformation.cloud.jeevanullas.in --role adminrole --configsets wordpress_install --region eucalyptus\n", | |
"owner": "root", | |
"group": "root", | |
"mode": "000400" | |
} | |
}, | |
"services": { | |
"sysvinit": { | |
"cfn-hup": { | |
"files": [ | |
"/etc/cfn/cfn-hup.conf", | |
"/etc/cfn/hooks.d/cfn-auto-reloader.conf" | |
], | |
"ensureRunning": "true", | |
"enabled": "true" | |
} | |
} | |
} | |
}, | |
"configSets": { | |
"wordpress_install": [ | |
"install_cfn", | |
"install_wordpress", | |
"configure_wordpress" | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment