Chef-gm

A suggested workflow using Chef.

Developed by @JasonRikard

Updated: April 14, 2014

Overview

Chef-gm (general manager) is a workflow and boilerplate for developing web applications. Its core is a combination of concepts built on Chef Solo, Vagrant and Knife for getting past the Chef learning curve. The boilerplate is a set of scripted sysadmin tasks that automate your team’s development and production environments. The workflow gives you some practical use cases and encourages further automation. Fork the Chef-gm repository to get started.

Details

A development to production workflow using

  • Git
  • Ruby
  • Ubuntu 12.04
  • Chef Solo
  • Vagrant
  • Virtual Box
  • Knife
  • Berkshelf
  • Capistrano

Configured Packages

  • Apache
  • PHP
  • MySQL
  • s3mcmd
  • NTP
  • Fail2ban
  • UFW
  • OpenSSH
  • Unattended-upgrades
  • Swap

Specs

Tested with

  • Ubuntu 12.04 64 bit
  • Vagrant 1.5.3
  • Virtual Box 4.3.10
  • Berkshelf 3.0.1
  • Chef 11.10.4
  • Ruby 2.1.0p0

Features

  • Examples and tutorials on how to provision this stack locally and remotely
  • Highly configurable parameters for packages in one place
  • Installs a LAMP stack with separate configurations for development and production
  • Stack tuned with defaults and suggested scaling
  • Upgraded 12.04 packages from dotdeb.org like PHP 5.4
  • Creates users and ssh keys and configures authorized users.
  • Creates directories and permissions for users and applications.
  • Adds aliases for repetitive CLI commands.
  • Adds deploy user keys to bitbucket via API
  • Imports database from AWS S3 or file.
  • Basic security with OpenSSH, UFW, and Fail2ban
  • Disables root user access and requires key pair authentication with OpenSSH
  • Implements a default firewall allowing traffic from ports 80 and 443 with UFW
  • Prevents multiple failed login attempts with Fail2ban
  • Configures directories for Capistrano application deployment
  • Enables swap space on VPS providers
  • Syncs internal clock with NTP
  • Auto updates security and version updates of Ubuntu packages daily with unattended upgrades
  • Backs up databases daily to AWS S3 via cron.
  • Configures Xdebug for development.
  • Uses APC for opcode cache
  • Configures http basic auth for access of dashboards like APC
  • Installs Google’s Page Speed Apache module.

Coming soon

  • Ops server role
  • Continuous integration with jenkins
  • Metrics with Graphite and Statsd
  • Nginx swappable recipe for apache
  • Event logging with Sentry
  • More use cases and tutorials

Benefits

These benefits aren’t exclusive to Chef-gm, they’re what you get from infrastructure as code.

  • Version controlled environments
  • Provision servers automatically
  • Reproducible environments

Chef-gm benefits

  • Less time on ops, more time on apps.
  • Working examples for multiple languages, frameworks, and web servers.
  • Working patterns for teams to adopt and adapt.
  • Development environments preconfigured with debugging and profiling tools.
  • Production environments preconfigured with monitoring and security.
  • Chef, vagrant, VPS pieces connected.
  • Examples showing basic horizontal scaling.

A work in progress

Rather than publish these articles in a blog or book, they are written and updated overtime with git and Jekyll. I believe this makes the optimal experience of knowing that the patterns are still valid as technology changes. As new tools and processes emerge, so will my workflow. The format was inspired by those who created phptherightway.com.

Audience

The purpose of this site is to share philosophies on web application development life cycles and workflow. I hope that it provides perspective to young developers and those considering starting a software company with little experience.

This site is intended for those who are already aware of the basics of web applications topics like HTML, CSS, Javascript, SQL and system administration. This site will attempt to provide a bigger picture to the moving parts of web applications like for scoping, developing, debugging, testing, measuring, deploying.

What’s with the name?

General managers oversee restaurant operations, in this case though, how to build a successful Chef environment.