Chef cookbook for managing apache vhosts backed by git repositories
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
attributes
recipes
templates/default
.gitignore
.kitchen.yml
Berksfile
CHANGELOG.md
Gemfile
LICENSE
README.md
Thorfile
Vagrantfile
chefignore
metadata.rb

README.md

apache2-git-site-cookbook

This cookbook configures a git-backed site on an apache2 vhost, allowing easy deployments without having to use ftp or capistrano.

A site can be redeployed by merging changes into a specified branch (default: the node's environment name)

The git repository will be re-synced every chef run, and can be configured from node attributes. Multiple sites can be created by listing additional sites in the attribute hash. A new user will be created for each site, and by default the files will be owned by this user, and the apache group.

Suggestions

Use the s3fs cookbook to mount persistent storage for use between your web instances, if necessary.

Supported Platforms

Ubuntu, possibly other unices. (Untested)

Dependencies

Cookbooks:

  • git
  • apache2

Recipes included

  • git::default
  • apache2::default

Attributes

Type Description Default
  • node['apache2-git-site']['sites-path']
String Root directory to contain cloned sites /var/www
  • node['apache2-git-site']['sites']
Hash Hash of site definitions Empty hash
  • node['apache2-git-site']['sites']{hash_key}*
String Site ID None
  • node['apache2-git-site']['sites']{hash_value}*
Hash Hash of site parameters None
  • node['apache2-git-site']['sites'][site_id]['documentroot']
String Document root relative to the root of the git repostitory htdocs
  • node['apache2-git-site']['sites'][site_id]['repository']
String URL for the git repository to be cloned None (required)
  • node['apache2-git-site']['sites'][site_id]['branch']
String Git branch to be checked out node['environment']
  • node['apache2-git-site']['sites'][site_id]['site-user']
String User that the checked-out files will be owned by www-#{site-id}
  • node['apache2-git-site']['sites'][site_id]['site-group']
String Group that the checked-out files will be owned by. Must already exist, and apache user should be a member. node['apache']['group']
  • node['apache2-git-site']['sites'][site_id]['servername']
String Vhost server name None (required)
  • node['apache2-git-site']['sites'][site_id]['serveradmin']
String Server admin webmaster@#{['apache2-git-site']['sites'][site_id]['servername']}
  • node['apache2-git-site']['sites'][site_id]['serveraliases']
String Array Vhost server aliases Empty array
  • node['apache2-git-site']['sites'][site_id]['default-options']
String Array Default apache options for documentroot directory ['FollowSymLinks', 'MultiViews', 'ExecCgi']
  • node['apache2-git-site']['sites'][site_id]['aliases']
Hash Array {"path": "root"} An array of hashes that define aliases, where 'path' is the alias path, and 'root' is the alias root relative to the checkout directory Empty array
  • node['apache2-git-site']['sites'][site_id]['extra-config']
String Array An array of additional configuration lines to be added to the apache virtual host configuration file. For example, adding rewrite rules or specifying a custom log. Empty array
  • node['apache2-git-site']['sites'][site_id]['sync-notify-commands']
String Array Specifies a sequence of commands to be executed from inside the git root directory (as the site user) when changes are pulled from the git repository Empty array
  • node['apache2-git-site']['common']
Hash Specifies a set of defaults which are merged with all site configurations. For example, you can add several lines to node['apache2-git-site']['common']['extra-config'] which will be added to all vhosts Empty array

Usage

apache2-git-site::default

Include apache2-git-site in your node's run_list:

{
  "run_list": [
    "recipe[apache2-git-site::default]"
  ]
}

Configure your sites in your node's attributes:

{
  "apache2-git-site": {
    "my_awesome_site": {
      "repository": "https://github.com/example/awesome.git",
      "servername": "www.example.org"
    }
  }
}

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (i.e. add-new-recipe)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request

License and Authors

License:: Apache v2.0 Author:: Simon Detheridge (simon@widgit.com)