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.
Use the s3fs cookbook to mount persistent storage for use between your web instances, if necessary.
Ubuntu, possibly other unices. (Untested)
Cookbooks:
- git
- apache2
Recipes included
- git::default
- apache2::default
Type | Description | Default |
---|---|---|
|
||
String | Root directory to contain cloned sites | /var/www |
|
||
Hash | Hash of site definitions | Empty hash |
|
||
String | Site ID | None |
|
||
Hash | Hash of site parameters | None |
|
||
String | Document root relative to the root of the git repostitory | htdocs |
|
||
String | URL for the git repository to be cloned | None (required) |
|
||
String | Git branch to be checked out | node['environment'] |
|
||
String | User that the checked-out files will be owned by | www-#{site-id} |
|
||
String | Group that the checked-out files will be owned by. Must already exist, and apache user should be a member. | node['apache']['group'] |
|
||
String | Vhost server name | None (required) |
|
||
String | Server admin | webmaster@#{['apache2-git-site']['sites'][site_id]['servername']} |
|
||
String Array | Vhost server aliases | Empty array |
|
||
String Array | Default apache options for documentroot directory | ['FollowSymLinks', 'MultiViews', 'ExecCgi'] |
|
||
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 |
|
||
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 |
|
||
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 |
|
||
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 |
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"
}
}
}
- Fork the repository on Github
- Create a named feature branch (i.e.
add-new-recipe
) - Write your change
- Write tests for your change (if applicable)
- Run the tests, ensuring they all pass
- Submit a Pull Request
License:: Apache v2.0 Author:: Simon Detheridge ([email protected])