Skip to content

allnightlong/application_static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

application_static cookbook

supermarket: https://supermarket.getchef.com/cookbooks/application_static
github: https://github.com/allnightlong/application_static

This is the simple chef cookbook to quick host static web sites with nginx. Based on excellent application cookbook, which is only providing LWRPs, this cookbook actually has recipe.

So after defining it with Berkshelf/Librarian, you have to provide as minimal config as possible, to make your sites working.

Config

Let's imagine you have several static websites, you want to host, each in it's own repository:

example1.com -> github.com/my-account/example1.com
example2.com -> bitbucket.org/my-account/example2.com
...

To get them running, you should do 3 steps.

1. Adding cookbook

First thing to do, is adding application_static cookbook to your chef installation.
Berkshelf example:

cookbook "application_static"

2. Create role

Then create appropriate role:

{
  "name": "static_sites",
  "override_attributes": {
    "nginx": {
      "default_site_enabled": false,
      "install_method": "repo"
    },
    "application_static": {
      "apps": [
        {
          "name": "example1.com",
          "url": "git@github.com:my-account/example1.com.git",
          "enabled": true
        },
        {
          "name": "example2.com",
          "url": "git@bitbucket.org:my-account/example2.com.git",
          "enabled": true
        }
      ],
      "deploy_key" : "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEA38rGcWTe5Iux2MtIgmbl08P0f3KZfJBCIvKES9oFFglqAbI7\n...........\n5qJkpABldGtXpWxrllpFvWDGSWdv8WYJW308dXIp2C5LjE3saTuhBTgain7GDs6P\np5lXlrB0zUGU92likbgEvIFN0lzkpYt02ccxTCCU6bIa9pTI3IBK\n-----END RSA PRIVATE KEY-----"
    }
  },
  "run_list": [
    "recipe[nginx]",
    "recipe[application_static]"
  ]
}

Note, that you shouldn't really store private key in role file, in favor of databags or even better encrypted databags.
Also, if you getting troubles with multiline private key, use this tip.

3. Apply role

knife node run_list add NODE_NAME role[static_sites]

That's basically it. After adding this role to node's run-list, your sites should be up and running.
This cookbook was tested on Ubuntu 14.04 LTS, but there is nothing os/platform/version specific, so it should work on any environment.
Pull-requests are very warm welcome.

TODO

  • Understand chef testing workflow and write tests.
  • Official support other OS(rpm-based) and scm (svn, hg).
  • Support all parameters of application cookbook (revision, migrate, rollback_on_error, etc).

About

Simple chef cookbook to quick host static web sites with nginx.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages