Skip to content
Deploying Wordpress on Amazon EC2 with Opscode Chef
Ruby Perl
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


[NOTE: See blog post with detailed instructions to go with this at]

Set of cookbooks to deploy a wordpress blog to an Amazon EC2 Instance. Mostly made up of stock Opscode Cookbooks. All the stock cookbooks are in the cookbooks directory. All the customizations are in site-cookbooks. The repo layout is based on the Opscode chef-repo.

The cookbook in site-cookbooks overrides the wordpress cookbook to properly deploy in EC2. I've added recipes to the wordpress so that it creates a user known as blog_updater that will own the wordpress files and will be used for doing wordpress updates. It also includes a reciepe to add a swap file for EC2 instances that have small memory (the t1.micro instance)

Includes a vsftpd cookbook I wrote. This allows secure sftp so that the Wordpress and wordpress plugins can be auto updated securely.

Repository Directories

This repository contains several directories, and each directory contains a README file that describes what it is for in greater detail, and how to use it for managing your systems with Chef.

  • certificates/ - SSL certificates generated by rake ssl_cert live here.
  • config/ - Contains the Rake configuration file, rake.rb.
  • cookbooks/ - Cookbooks that were downloaded from the repository. They are unchanged
  • site-cookboos/ - Cookbook additions or custom overrides done by me for this applicaiton
  • data_bags/ - Store data bags and items in .json in the repository.
  • roles/ - Store roles in .rb or .json in the repository.


Rake Tasks

The repository contains a Rakefile that includes tasks that are installed with the Chef libraries. To view the tasks available with in the repository with a brief description, run rake -T.

The default task (default) is run when executing rake with no arguments. It will call the task test_cookbooks.

The following tasks are not directly replaced by knife sub-commands.

  • bundle_cookbook[cookbook] - Creates cookbook tarballs in the pkgs/ dir.
  • install - Calls update, roles and upload_cookbooks Rake tasks.
  • ssl_cert - Create self-signed SSL certificates in certificates/ dir.
  • update - Update the repository from source control server, understands git and svn.

The following tasks duplicate functionality from knife and may be removed in a future version of Chef.

  • metadata - replaced by knife cookbook metadata -a.
  • new_cookbook - replaced by knife cookbook create.
  • role[role_name] - replaced by knife role from file.
  • roles - iterates over the roles and uploads with knife role from file.
  • test_cookbooks - replaced by knife cookbook test -a.
  • test_cookbook[cookbook] - replaced by knife cookbook test COOKBOOK.
  • upload_cookbooks - replaced by knife cookbook upload -a.
  • upload_cookbook[cookbook] - replaced by knife cookbook upload COOKBOOK.


The repository uses two configuration files.

  • config/rake.rb
  • .chef/knife.rb

The first, config/rake.rb configures the Rakefile in two sections.

  • Constants used in the ssl_cert task for creating the certificates.
  • Constants that set the directory locations used in various tasks.

If you use the ssl_cert task, change the values in the config/rake.rb file appropriately. These values were also used in the new_cookbook task, but that task is replaced by the knife cookbook create command which can be configured below.

The second config file, .chef/knife.rb is a repository specific configuration file for knife. If you're using the Opscode Platform, you can download one for your organization from the management console. If you're using the Open Source Chef Server, you can generate a new one with knife configure. For more information about configuring Knife, see the Knife documentation.

Next Steps

Read the README file in each of the subdirectories for more information about what goes in those directories.

You can’t perform that action at this time.