Skip to content

OPLZZ/pickwick-chef

Repository files navigation

Infrastructure Chef cookbooks


Chef cookbooks for project damepraci.cz.

Provided cookbooks

monitoring

Simple cookbook for service monitoring using Monit.

Provides recipes for elasticsearch, nginx and redis monitoring.

applications

Cookbook for provisioning applications which are necessary for damepraci.cz project.

Recipes:

Provided roles

Whole infrastructure is divided into several roles.

Installation

Prerequisites

First, you need to have a valid Chef Server account, your user validation key, and your organization validation key.

The easiest way is to create a free account in Hosted Chef, provided by Opscode.

You need to export the following environment variables for the provisioning scripts:

export CHEF_ORGANIZATION='<your organization name>'
export CHEF_ORGANIZATION_KEY='/path/to/your/your-organization-validator.pem'
export NGINX_USER='<nginx username>'
export NGINX_PASSWORD='<nginx user password>'
export MONIT_USER='<monit username>'
export MONIT_PASSWORD='<monit user password>'
export MONIT_ALERT_EMAIL='<email for alerts>'
export MONIT_FROM_EMAIL='<email from>'
export MONIT_SMTP_SERVER='<smtp server>'
export MONIT_SMTP_PORT='<smtp port>'
export MONIT_SMTP_USER='<smtp username>'
export MONIT_SMTP_PASSWORD='<smtp password>'
export PICKWICK_API_URL='<url of API>'
export PICKWICK_API_TOKEN='<read only API token>'
export PICKWICK_API_RW_TOKEN='<API token>'
export PICKWICK_ADMIN_USERNAME='<admin username>'
export PICKWICK_ADMIN_PASSWORD='<admin password>'
export SIDEKIQ_USERNAME='<sidekiq username>'
export SIDEKIQ_PASSWORD='<sidekiq password>'

Installation

git clone https://github.com/OPLZZ/pickwick-chef.git
cd pickwick-chef

... install the required rubygems:

bundle install

... install the site cookbooks with Berkshelf:

berks vendor ./site-cookbooks/

... upload the cookbooks and roles to Chef Server:

bundle exec rake chef:sync

... build server

DigitalOcean preparation

... create ~/.ssh/digitalocean-damepraci using ssh-keygen

... set environment variable to public key

export SSH_PUBLIC_FILE=~/.ssh/digitalocean-damepraci.pub
export SSH_IDENTITY_FILE=~/.ssh/digitalocean-damepraci

... add ssh key to digitalocean account

bundle exec knife digital_ocean sshkey create --sshkey-name digitalocean-damepraci \
                                              --public-key $SSH_PUBLIC_FILE

... get ssh key id

export SSH_KEY_ID=$(bundle exec knife digital_ocean sshkey list | grep digitalocean-damepraci | cut -d' ' -f1)

... create droplet

bundle exec knife digital_ocean droplet create --server-name damepraci.cz \
                                               --image debian-7-x64 \
                                               --location fra1 \
                                               --size 2gb \
                                               --ssh-keys $SSH_KEY_ID \
                                               --bootstrap \
                                               --distro debian \
                                               --ssh-port 22 \
                                               --identity-file $SSH_IDENTITY_FILE

... create volume named damepraci.cz using DigitalOcean UI and attach it to the damepraci.cz droplet

... add desired role to the node

bundle exec knife node run_list add damepraci.cz "role[whole_stack]"

... run chef-client again

knife ssh "name:damepraci.cz" -a ipaddress -x root --identity-file $SSH_IDENTITY_FILE chef-client

Funding

Project of Operational Programme Human Resources and Employment No. CZ.1.04/5.1.01/77.00440. The project No. CZ.1.04/5.1.01/77.00440 was funded from the European Social Fund through the Operational Programme Human Resources and Employment and the state budget of Czech Republic.

Releases

No releases published

Packages

No packages published