From afa0da98850b53ccecd65e5646b30d12d5883e3b Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Thu, 27 Jun 2013 18:35:04 -0700 Subject: [PATCH] Import wordpress version 1.1.2 --- cookbooks/wordpress/.gitignore | 14 ++ cookbooks/wordpress/.kitchen.yml | 37 ++++ cookbooks/wordpress/Berksfile | 8 + cookbooks/wordpress/CHANGELOG.md | 45 ++++ cookbooks/wordpress/CONTRIBUTING | 29 +++ cookbooks/wordpress/Gemfile | 5 + cookbooks/wordpress/LICENSE | 201 ++++++++++++++++++ cookbooks/wordpress/README.md | 80 +++++++ cookbooks/wordpress/TESTING.md | 25 +++ cookbooks/wordpress/attributes/default.rb | 28 +++ cookbooks/wordpress/metadata.json | 191 +++++++++++++++++ cookbooks/wordpress/metadata.rb | 76 +++++++ cookbooks/wordpress/recipes/default.rb | 145 +++++++++++++ .../templates/default/grants.sql.erb | 5 + .../templates/default/wordpress.conf.erb | 26 +++ .../templates/default/wp-config.php.erb | 76 +++++++ 16 files changed, 991 insertions(+) create mode 100644 cookbooks/wordpress/.gitignore create mode 100644 cookbooks/wordpress/.kitchen.yml create mode 100644 cookbooks/wordpress/Berksfile create mode 100644 cookbooks/wordpress/CHANGELOG.md create mode 100644 cookbooks/wordpress/CONTRIBUTING create mode 100644 cookbooks/wordpress/Gemfile create mode 100644 cookbooks/wordpress/LICENSE create mode 100644 cookbooks/wordpress/README.md create mode 100644 cookbooks/wordpress/TESTING.md create mode 100644 cookbooks/wordpress/attributes/default.rb create mode 100644 cookbooks/wordpress/metadata.json create mode 100644 cookbooks/wordpress/metadata.rb create mode 100644 cookbooks/wordpress/recipes/default.rb create mode 100644 cookbooks/wordpress/templates/default/grants.sql.erb create mode 100644 cookbooks/wordpress/templates/default/wordpress.conf.erb create mode 100644 cookbooks/wordpress/templates/default/wp-config.php.erb diff --git a/cookbooks/wordpress/.gitignore b/cookbooks/wordpress/.gitignore new file mode 100644 index 0000000..dd1e425 --- /dev/null +++ b/cookbooks/wordpress/.gitignore @@ -0,0 +1,14 @@ +.vagrant +Berksfile.lock +Gemfile.lock +*~ +*# +.#* +\#*# +.*.sw[a-z] +*.un~ +.bundle +.cache +.kitchen +bin +.kitchen.local.yml diff --git a/cookbooks/wordpress/.kitchen.yml b/cookbooks/wordpress/.kitchen.yml new file mode 100644 index 0000000..9343555 --- /dev/null +++ b/cookbooks/wordpress/.kitchen.yml @@ -0,0 +1,37 @@ +--- +driver_plugin: vagrant +platforms: +- name: ubuntu-12.04 + driver_config: + box: opscode-ubuntu-12.04 + box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box + require_chef_omnibus: true + run_list: + - recipe[apt] +- name: ubuntu-10.04 + driver_config: + box: opscode-ubuntu-10.04 + box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box + require_chef_omnibus: true + run_list: + - recipe[apt] +- name: centos-6.4 + driver_config: + box: opscode-centos-6.4 + box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box + require_chef_omnibus: true +- name: centos-5.9 + driver_config: + box: opscode-centos-5.9 + box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box + require_chef_omnibus: true + +suites: +- name: default + run_list: + - recipe[wordpress] + attributes: + mysql: + server_root_password: "Please-Dont-Use-In-Production" + server_debian_password: "Please-Dont-Use-In-Production" + server_repl_password: "Please-Dont-Use-In-Production" \ No newline at end of file diff --git a/cookbooks/wordpress/Berksfile b/cookbooks/wordpress/Berksfile new file mode 100644 index 0000000..34a3b2d --- /dev/null +++ b/cookbooks/wordpress/Berksfile @@ -0,0 +1,8 @@ +site :opscode + +metadata + +group :integration do + cookbook "apt" + cookbook "yum" +end diff --git a/cookbooks/wordpress/CHANGELOG.md b/cookbooks/wordpress/CHANGELOG.md new file mode 100644 index 0000000..abafe87 --- /dev/null +++ b/cookbooks/wordpress/CHANGELOG.md @@ -0,0 +1,45 @@ +## v1.1.0 + +This version updates support for test kitchen to version 1.0. See +TESTING.md + +### Bug + +- [COOK-1393]: wordpress recipe should use mysql::ruby to ensure ruby + extension is installed +- [COOK-2984]: wordpress cookbook has foodcritic failures + +### Improvement + +- [COOK-2661]: Allow downloads from other repos for wordpress install + +## v1.0.0: + +* [COOK-1127] - update defaults to latest version +* [COOK-1222] - support installing "latest" version +* [COOK-1271] - Wordpress cookbook generates new password on every + chef run + +## v0.8.8: + +* [COOK-826] - recipe doesn't quote password string + +## v0.8.6: + +* [COOK-534] - allow server_aliases to overridden by an attribute +* [COOK-799] - fixed disables .htaccess breaking permalink feature +* [COOK-820] - guard node.save with check for chef-solo in our cookbooks + +## v0.8.4: + +* [COOK-406] - wp-config.php.erb has wrong CRLF encoding +* Dropping explicit support for Red Hat platforms due to issues in php + and mysql cookbooks (COOK-603, COOK-672, COOK-816, COOK-679) + +## v0.8.2: + +* [COOK-435] Don't set the mysql root user password in wordpress cookbook +* [COOK-535] - recursively create the directory +* RHEL/CentOS/Fedora support (yeah!) +* cleaned up node attribute keys +* cleaned up README.md diff --git a/cookbooks/wordpress/CONTRIBUTING b/cookbooks/wordpress/CONTRIBUTING new file mode 100644 index 0000000..89ac873 --- /dev/null +++ b/cookbooks/wordpress/CONTRIBUTING @@ -0,0 +1,29 @@ +If you would like to contribute, please open a ticket in JIRA: + +* http://tickets.opscode.com + +Create the ticket in the COOK project and use the cookbook name as the +component. + +For all code contributions, we ask that contributors sign a +contributor license agreement (CLA). Instructions may be found here: + +* http://wiki.opscode.com/display/chef/How+to+Contribute + +When contributing changes to individual cookbooks, please do not +modify the version number in the metadata.rb. Also please do not +update the CHANGELOG.md for a new version. Not all changes to a +cookbook may be merged and released in the same versions. Opscode will +handle the version updates during the release process. You are welcome +to correct typos or otherwise make updates to documentation in the +README. + +If a contribution adds new platforms or platform versions, indicate +such in the body of the commit message(s), and update the relevant +COOK ticket. When writing commit messages, it is helpful for others if +you indicate the COOK ticket. For example: + + git commit -m '[COOK-1041] Updated pool resource to correctly delete.' + +In the ticket itself, it is also helpful if you include log output of +a successful Chef run, but this is not absolutely required. diff --git a/cookbooks/wordpress/Gemfile b/cookbooks/wordpress/Gemfile new file mode 100644 index 0000000..f04cf4b --- /dev/null +++ b/cookbooks/wordpress/Gemfile @@ -0,0 +1,5 @@ +source :rubygems + +group :kitchen do + gem 'test-kitchen', '< 1.0' +end diff --git a/cookbooks/wordpress/LICENSE b/cookbooks/wordpress/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/cookbooks/wordpress/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/cookbooks/wordpress/README.md b/cookbooks/wordpress/README.md new file mode 100644 index 0000000..bba0994 --- /dev/null +++ b/cookbooks/wordpress/README.md @@ -0,0 +1,80 @@ +Description +=========== + +Installs and configures Wordpress according to the instructions at http://codex.wordpress.org/Installing_WordPress. Does not set up a wordpress blog. You will need to do this manually by going to http://hostname/wp-admin/install.php (this URL may be different if you change the attribute values). + +Requirements +============ + +Platform +-------- + +* Debian, Ubuntu + +Tested on: + +* Ubuntu 9.04, 9.10, 10.04 + +Cookbooks +--------- + +* mysql +* php +* apache2 +* opensssl (uses library to generate secure passwords) + +Attributes +========== + +* `node['wordpress']['version']` - Set the version to download. Using 'latest' (the default) will install the most current version. +* `node['wordpress']['checksum']` - sha256sum of the tarball, make sure this matches for the version! (Not used for 'latest' version.) +* `node['wordpress']['dir']` - Set the location to place wordpress files. Default is /var/www. +* `node['wordpress']['db']['database']` - Wordpress will use this MySQL database to store its data. +* `node['wordpress']['db']['user']` - Wordpress will connect to MySQL using this user. +* `node['wordpress']['db']['password']` - Password for the Wordpress MySQL user. The default is a randomly generated string. +* `node['wordpress']['server_aliases']` - Array of ServerAliases used in apache vhost. Default is `node['fqdn']`. + +Attributes will probably never need to change (these all default to randomly generated strings): + +* `node['wordpress']['keys']['auth']` +* `node['wordpress']['keys']['secure_auth']` +* `node['wordpress']['keys']['logged_in']` +* `node['wordpress']['keys']['nonce']` + +The random generation is handled with the secure_password method in the openssl cookbook which is a cryptographically secure random generator and not predictable like the random method in the ruby standard library. + +Usage +===== + +If a different version than the default is desired, download that version and get the SHA256 checksum (sha256sum on Linux systems), and set the version and checksum attributes. + +Add the "wordpress" recipe to your node's run list or role, or include the recipe in another cookbook. + +Chef will install and configure mysql, php, and apache2 according to the instructions at http://codex.wordpress.org/Installing_WordPress. Does not set up a wordpress blog. You will need to do this manually by going to http://hostname/wp-admin/install.php (this URL may be different if you change the attribute values). + +The mysql::server recipe needs to come first, and contain an execute resource to install mysql privileges from the grants.sql template in this cookbook. + +## Note about MySQL + +This cookbook will decouple the mysql::server and be smart about detecting whether to use a local database or find a database server in the environment in a later version. + +License and Author +================== + +Author:: Barry Steinglass (barry@opscode.com) +Author:: Joshua Timberman (joshua@opscode.com) +Author:: Seth Chisamore (schisamo@opscode.com) + +Copyright:: 2010-2011, Opscode, Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/cookbooks/wordpress/TESTING.md b/cookbooks/wordpress/TESTING.md new file mode 100644 index 0000000..e29ff7c --- /dev/null +++ b/cookbooks/wordpress/TESTING.md @@ -0,0 +1,25 @@ +This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements. + +1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site. +2. You must have Vagrant 1.1 installed. +3. You must have a "sane" Ruby 1.9.3 environment. + +Once the above requirements are met, install the additional requirements: + +Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment. + + vagrant plugin install vagrant-berkshelf + gem install berkshelf + +Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version). + + gem install test-kitchen --pre + +Install the Vagrant driver for Test Kitchen. + + gem install kitchen-vagrant + +Once the above are installed, you should be able to run Test Kitchen: + + kitchen list + kitchen test diff --git a/cookbooks/wordpress/attributes/default.rb b/cookbooks/wordpress/attributes/default.rb new file mode 100644 index 0000000..e8574b0 --- /dev/null +++ b/cookbooks/wordpress/attributes/default.rb @@ -0,0 +1,28 @@ +# +# Author:: Barry Steinglass () +# Cookbook Name:: wordpress +# Attributes:: wordpress +# +# Copyright 2009-2010, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# General settings +default['wordpress']['version'] = "latest" +default['wordpress']['checksum'] = "" +default['wordpress']['repourl'] = "http://wordpress.org/" +default['wordpress']['dir'] = "/var/www/wordpress" +default['wordpress']['db']['database'] = "wordpressdb" +default['wordpress']['db']['user'] = "wordpressuser" +default['wordpress']['server_aliases'] = [node['fqdn']] diff --git a/cookbooks/wordpress/metadata.json b/cookbooks/wordpress/metadata.json new file mode 100644 index 0000000..2784a58 --- /dev/null +++ b/cookbooks/wordpress/metadata.json @@ -0,0 +1,191 @@ +{ + "name": "wordpress", + "description": "Installs/Configures WordPress", + "long_description": "Description\n===========\n\nInstalls and configures Wordpress according to the instructions at http://codex.wordpress.org/Installing_WordPress. Does not set up a wordpress blog. You will need to do this manually by going to http://hostname/wp-admin/install.php (this URL may be different if you change the attribute values).\n\nRequirements\n============\n\nPlatform\n--------\n\n* Debian, Ubuntu\n\nTested on:\n\n* Ubuntu 9.04, 9.10, 10.04\n\nCookbooks\n---------\n\n* mysql\n* php\n* apache2\n* opensssl (uses library to generate secure passwords)\n\nAttributes\n==========\n\n* `node['wordpress']['version']` - Set the version to download. Using 'latest' (the default) will install the most current version.\n* `node['wordpress']['checksum']` - sha256sum of the tarball, make sure this matches for the version! (Not used for 'latest' version.)\n* `node['wordpress']['dir']` - Set the location to place wordpress files. Default is /var/www.\n* `node['wordpress']['db']['database']` - Wordpress will use this MySQL database to store its data.\n* `node['wordpress']['db']['user']` - Wordpress will connect to MySQL using this user.\n* `node['wordpress']['db']['password']` - Password for the Wordpress MySQL user. The default is a randomly generated string.\n* `node['wordpress']['server_aliases']` - Array of ServerAliases used in apache vhost. Default is `node['fqdn']`.\n\nAttributes will probably never need to change (these all default to randomly generated strings):\n\n* `node['wordpress']['keys']['auth']`\n* `node['wordpress']['keys']['secure_auth']`\n* `node['wordpress']['keys']['logged_in']`\n* `node['wordpress']['keys']['nonce']`\n\nThe random generation is handled with the secure_password method in the openssl cookbook which is a cryptographically secure random generator and not predictable like the random method in the ruby standard library.\n\nUsage\n=====\n\nIf a different version than the default is desired, download that version and get the SHA256 checksum (sha256sum on Linux systems), and set the version and checksum attributes.\n\nAdd the \"wordpress\" recipe to your node's run list or role, or include the recipe in another cookbook.\n\nChef will install and configure mysql, php, and apache2 according to the instructions at http://codex.wordpress.org/Installing_WordPress. Does not set up a wordpress blog. You will need to do this manually by going to http://hostname/wp-admin/install.php (this URL may be different if you change the attribute values).\n\nThe mysql::server recipe needs to come first, and contain an execute resource to install mysql privileges from the grants.sql template in this cookbook.\n\n## Note about MySQL\n\nThis cookbook will decouple the mysql::server and be smart about detecting whether to use a local database or find a database server in the environment in a later version.\n\nLicense and Author\n==================\n\nAuthor:: Barry Steinglass (barry@opscode.com)\nAuthor:: Joshua Timberman (joshua@opscode.com)\nAuthor:: Seth Chisamore (schisamo@opscode.com)\n\nCopyright:: 2010-2011, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n", + "maintainer": "Barry Steinglass", + "maintainer_email": "cookbooks@opscode.com", + "license": "Apache 2.0", + "platforms": { + "debian": ">= 0.0.0", + "ubuntu": ">= 0.0.0" + }, + "dependencies": { + "php": ">= 0.0.0", + "openssl": ">= 0.0.0", + "apache2": ">= 0.99.4", + "mysql": ">= 1.0.5", + "build-essential": ">= 0.0.0" + }, + "recommendations": { + }, + "suggestions": { + }, + "conflicting": { + }, + "providing": { + }, + "replacing": { + }, + "attributes": { + "WordPress/version": { + "display_name": "WordPress download version", + "description": "Version of WordPress to download from the WordPress site or 'latest' for the current release.", + "default": "latest", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/checksum": { + "display_name": "WordPress tarball checksum", + "description": "Checksum of the tarball for the version specified.", + "default": "", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/dir": { + "display_name": "WordPress installation directory", + "description": "Location to place WordPress files.", + "default": "/var/www/wordpress", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/db/database": { + "display_name": "WordPress MySQL database", + "description": "WordPress will use this MySQL database to store its data.", + "default": "wordpressdb", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/db/user": { + "display_name": "WordPress MySQL user", + "description": "WordPress will connect to MySQL using this user.", + "default": "wordpressuser", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/db/password": { + "display_name": "WordPress MySQL password", + "description": "Password for the WordPress MySQL user.", + "default": "randomly generated", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/keys/auth": { + "display_name": "WordPress auth key", + "description": "WordPress auth key.", + "default": "randomly generated", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/keys/secure_auth": { + "display_name": "WordPress secure auth key", + "description": "WordPress secure auth key.", + "default": "randomly generated", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/keys/logged_in": { + "display_name": "WordPress logged-in key", + "description": "WordPress logged-in key.", + "default": "randomly generated", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/keys/nonce": { + "display_name": "WordPress nonce key", + "description": "WordPress nonce key.", + "default": "randomly generated", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + }, + "WordPress/server_aliases": { + "display_name": "WordPress Server Aliases", + "description": "WordPress Server Aliases", + "default": "FQDN", + "choice": [ + + ], + "calculated": false, + "type": "string", + "required": "optional", + "recipes": [ + + ] + } + }, + "groupings": { + }, + "recipes": { + "WordPress": "Installs and configures WordPress LAMP stack on a single system" + }, + "version": "1.1.2" +} \ No newline at end of file diff --git a/cookbooks/wordpress/metadata.rb b/cookbooks/wordpress/metadata.rb new file mode 100644 index 0000000..713df08 --- /dev/null +++ b/cookbooks/wordpress/metadata.rb @@ -0,0 +1,76 @@ +name "wordpress" +maintainer "Barry Steinglass" +maintainer_email "cookbooks@opscode.com" +license "Apache 2.0" +description "Installs/Configures WordPress" +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version "1.1.2" + +recipe "WordPress", "Installs and configures WordPress LAMP stack on a single system" + +%w{ php openssl }.each do |cb| + depends cb +end + +depends "apache2", ">= 0.99.4" +depends "mysql", ">= 1.0.5" +depends "build-essential" + +%w{ debian ubuntu }.each do |os| + supports os +end + +attribute "WordPress/version", + :display_name => "WordPress download version", + :description => "Version of WordPress to download from the WordPress site or 'latest' for the current release.", + :default => "latest" + +attribute "WordPress/checksum", + :display_name => "WordPress tarball checksum", + :description => "Checksum of the tarball for the version specified.", + :default => "" + +attribute "WordPress/dir", + :display_name => "WordPress installation directory", + :description => "Location to place WordPress files.", + :default => "/var/www/wordpress" + +attribute "WordPress/db/database", + :display_name => "WordPress MySQL database", + :description => "WordPress will use this MySQL database to store its data.", + :default => "wordpressdb" + +attribute "WordPress/db/user", + :display_name => "WordPress MySQL user", + :description => "WordPress will connect to MySQL using this user.", + :default => "wordpressuser" + +attribute "WordPress/db/password", + :display_name => "WordPress MySQL password", + :description => "Password for the WordPress MySQL user.", + :default => "randomly generated" + +attribute "WordPress/keys/auth", + :display_name => "WordPress auth key", + :description => "WordPress auth key.", + :default => "randomly generated" + +attribute "WordPress/keys/secure_auth", + :display_name => "WordPress secure auth key", + :description => "WordPress secure auth key.", + :default => "randomly generated" + +attribute "WordPress/keys/logged_in", + :display_name => "WordPress logged-in key", + :description => "WordPress logged-in key.", + :default => "randomly generated" + +attribute "WordPress/keys/nonce", + :display_name => "WordPress nonce key", + :description => "WordPress nonce key.", + :default => "randomly generated" + +attribute "WordPress/server_aliases", + :display_name => "WordPress Server Aliases", + :description => "WordPress Server Aliases", + :default => "FQDN" diff --git a/cookbooks/wordpress/recipes/default.rb b/cookbooks/wordpress/recipes/default.rb new file mode 100644 index 0000000..c8630ca --- /dev/null +++ b/cookbooks/wordpress/recipes/default.rb @@ -0,0 +1,145 @@ +# +# Cookbook Name:: wordpress +# Recipe:: default +# +# Copyright 2009-2010, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "apache2" +include_recipe "mysql::server" +include_recipe "mysql::ruby" +include_recipe "php" +include_recipe "php::module_mysql" +include_recipe "apache2::mod_php5" + +if node.has_key?("ec2") + server_fqdn = node['ec2']['public_hostname'] +else + server_fqdn = node['fqdn'] +end + +node.set_unless['wordpress']['db']['password'] = secure_password +node.set_unless['wordpress']['keys']['auth'] = secure_password +node.set_unless['wordpress']['keys']['secure_auth'] = secure_password +node.set_unless['wordpress']['keys']['logged_in'] = secure_password +node.set_unless['wordpress']['keys']['nonce'] = secure_password + + +if node['wordpress']['version'] == 'latest' + # WordPress.org does not provide a sha256 checksum, so we'll use the sha1 they do provide + require 'digest/sha1' + require 'open-uri' + local_file = "#{Chef::Config[:file_cache_path]}/wordpress-latest.tar.gz" + latest_sha1 = open('http://wordpress.org/latest.tar.gz.sha1') {|f| f.read } + unless File.exists?(local_file) && ( Digest::SHA1.hexdigest(File.read(local_file)) == latest_sha1 ) + remote_file "#{Chef::Config[:file_cache_path]}/wordpress-latest.tar.gz" do + source "http://wordpress.org/latest.tar.gz" + mode "0644" + end + end +else + remote_file "#{Chef::Config[:file_cache_path]}/wordpress-#{node['wordpress']['version']}.tar.gz" do + source "#{node['wordpress']['repourl']}/wordpress-#{node['wordpress']['version']}.tar.gz" + mode "0644" + end +end + +directory node['wordpress']['dir'] do + owner "root" + group "root" + mode "0755" + action :create + recursive true +end + +execute "untar-wordpress" do + cwd node['wordpress']['dir'] + command "tar --strip-components 1 -xzf #{Chef::Config[:file_cache_path]}/wordpress-#{node['wordpress']['version']}.tar.gz" + creates "#{node['wordpress']['dir']}/wp-settings.php" +end + +execute "mysql-install-wp-privileges" do + command "/usr/bin/mysql -u root -p\"#{node['mysql']['server_root_password']}\" < #{node['mysql']['conf_dir']}/wp-grants.sql" + action :nothing +end + +template "#{node['mysql']['conf_dir']}/wp-grants.sql" do + source "grants.sql.erb" + owner "root" + group "root" + mode "0600" + variables( + :user => node['wordpress']['db']['user'], + :password => node['wordpress']['db']['password'], + :database => node['wordpress']['db']['database'] + ) + notifies :run, "execute[mysql-install-wp-privileges]", :immediately +end + +execute "create #{node['wordpress']['db']['database']} database" do + command "/usr/bin/mysqladmin -u root -p\"#{node['mysql']['server_root_password']}\" create #{node['wordpress']['db']['database']}" + not_if do + # Make sure gem is detected if it was just installed earlier in this recipe + require 'rubygems' + Gem.clear_paths + require 'mysql' + m = Mysql.new("localhost", "root", node['mysql']['server_root_password']) + m.list_dbs.include?(node['wordpress']['db']['database']) + end + notifies :create, "ruby_block[save node data]", :immediately unless Chef::Config[:solo] +end + +# save node data after writing the MYSQL root password, so that a failed chef-client run that gets this far doesn't cause an unknown password to get applied to the box without being saved in the node data. +unless Chef::Config[:solo] + ruby_block "save node data" do + block do + node.save + end + action :create + end +end + +log "wordpress_install_message" do + action :nothing + message "Navigate to 'http://#{server_fqdn}/wp-admin/install.php' to complete wordpress installation" +end + +template "#{node['wordpress']['dir']}/wp-config.php" do + source "wp-config.php.erb" + owner "root" + group "root" + mode "0644" + variables( + :database => node['wordpress']['db']['database'], + :user => node['wordpress']['db']['user'], + :password => node['wordpress']['db']['password'], + :auth_key => node['wordpress']['keys']['auth'], + :secure_auth_key => node['wordpress']['keys']['secure_auth'], + :logged_in_key => node['wordpress']['keys']['logged_in'], + :nonce_key => node['wordpress']['keys']['nonce'] + ) + notifies :write, "log[wordpress_install_message]" +end + +apache_site "000-default" do + enable false +end + +web_app "wordpress" do + template "wordpress.conf.erb" + docroot node['wordpress']['dir'] + server_name server_fqdn + server_aliases node['wordpress']['server_aliases'] +end diff --git a/cookbooks/wordpress/templates/default/grants.sql.erb b/cookbooks/wordpress/templates/default/grants.sql.erb new file mode 100644 index 0000000..197a79f --- /dev/null +++ b/cookbooks/wordpress/templates/default/grants.sql.erb @@ -0,0 +1,5 @@ +GRANT ALL ON <%= @database %>.* TO '<%= @user %>'@'%' IDENTIFIED BY '<%= @password %>'; +GRANT ALL ON <%= @database %>.* TO '<%= @user %>'@'<%= node['fqdn'] %>' IDENTIFIED BY '<%= @password %>'; +GRANT ALL ON <%= @database %>.* TO '<%= @user %>'@'localhost' IDENTIFIED BY '<%= @password %>'; + +FLUSH PRIVILEGES; diff --git a/cookbooks/wordpress/templates/default/wordpress.conf.erb b/cookbooks/wordpress/templates/default/wordpress.conf.erb new file mode 100644 index 0000000..56b75f2 --- /dev/null +++ b/cookbooks/wordpress/templates/default/wordpress.conf.erb @@ -0,0 +1,26 @@ + + ServerName <%= @params[:server_name] %> + ServerAlias <% @params[:server_aliases].each do |a| %><%= a %> <% end %> + DocumentRoot <%= @params[:docroot] %> + + > + Options FollowSymLinks + AllowOverride FileInfo Options + Order allow,deny + Allow from all + + + + Options FollowSymLinks + AllowOverride None + + + LogLevel info + ErrorLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-error.log + CustomLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-access.log combined + + RewriteEngine On + RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log + RewriteLogLevel 0 + + diff --git a/cookbooks/wordpress/templates/default/wp-config.php.erb b/cookbooks/wordpress/templates/default/wp-config.php.erb new file mode 100644 index 0000000..be4fd2e --- /dev/null +++ b/cookbooks/wordpress/templates/default/wp-config.php.erb @@ -0,0 +1,76 @@ +'); + +/** MySQL database username */ +define('DB_USER', '<%= @user %>'); + +/** MySQL database password */ +define('DB_PASSWORD', '<%= @password %>'); + +/** MySQL hostname */ +define('DB_HOST', 'localhost'); + +/** Database Charset to use in creating database tables. */ +define('DB_CHARSET', 'utf8'); + +/** The Database Collate type. Don't change this if in doubt. */ +define('DB_COLLATE', ''); + +/**#@+ + * Authentication Unique Keys. + * + * Change these to different unique phrases! + * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/ WordPress.org secret-key service} + * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. + * + * @since 2.6.0 + */ +define('AUTH_KEY', '<%= @auth_key %>'); +define('SECURE_AUTH_KEY', '<%= @secure_auth_key %>'); +define('LOGGED_IN_KEY', '<%= @logged_in_key %>'); +define('NONCE_KEY', '<%= @nonce_key %>'); +/**#@-*/ + +/** + * WordPress Database Table prefix. + * + * You can have multiple installations in one database if you give each a unique + * prefix. Only numbers, letters, and underscores please! + */ +$table_prefix = 'wp_'; + +/** + * WordPress Localized Language, defaults to English. + * + * Change this to localize WordPress. A corresponding MO file for the chosen + * language must be installed to wp-content/languages. For example, install + * de.mo to wp-content/languages and set WPLANG to 'de' to enable German + * language support. + */ +define ('WPLANG', ''); + +/* That's all, stop editing! Happy blogging. */ + +/** WordPress absolute path to the Wordpress directory. */ +if ( !defined('ABSPATH') ) + define('ABSPATH', dirname(__FILE__) . '/'); + +/** Sets up WordPress vars and included files. */ +require_once(ABSPATH . 'wp-settings.php');