Created
August 5, 2014 08:16
-
-
Save predakanga/cf49bd623f02f4bdc0bf to your computer and use it in GitHub Desktop.
Devbox cookbook's default recipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: devbox | |
# Recipe:: default | |
# | |
# Copyright 2013, Lachlan Pease | |
# | |
# All rights reserved - Do Not Redistribute | |
# | |
include_recipe 'nginx::commons_dir' | |
# Install the SSL certs for nginx | |
cookbook_file "/etc/nginx/ssl-cert-snakeoil.pem" do | |
source "ssl-cert-snakeoil.pem" | |
mode 00644 | |
end | |
cookbook_file "/etc/nginx/ssl-cert-snakeoil.key" do | |
source "ssl-cert-snakeoil.key" | |
mode 00640 | |
end | |
# Fix the "not a tty" error | |
cookbook_file "/root/.profile" do | |
source "root_profile" | |
mode 00644 | |
end | |
# Create the mysql conf.d directory, since the package doesn't any more | |
directory "/etc/mysql/conf.d" do | |
mode 00755 | |
owner "root" | |
group "root" | |
action :create | |
recursive true | |
end | |
# Real dependencies | |
include_recipe 'nginx' | |
include_recipe 'percona::client' | |
include_recipe 'percona::server' | |
include_recipe 'java' # For ES | |
include_recipe 'elasticsearch' | |
include_recipe 'elasticsearch::plugins' # For ES-Head | |
include_recipe 'gdebi' # For installing .debs with dependencies | |
include_recipe 'memcached' | |
include_recipe 'git' # Mostly for composer | |
include_recipe 'rabbitmq' | |
# PHP itself | |
include_recipe 'php' | |
include_recipe 'php::fpm' | |
# PHP modules | |
include_recipe 'php::module_common' # Intl, MCrypt, GD | |
include_recipe 'php::module_apc' | |
include_recipe 'php::module_curl' | |
include_recipe 'php::module_memcache' | |
include_recipe 'php::module_mysql' | |
# Our own custom additions | |
include_recipe 'devbox::php_modules' | |
include_recipe 'devbox::graphing' | |
include_recipe 'btndev::xinetd' | |
include_recipe 'btndev::xz' | |
# Overwrite the nginx default site template | |
begin | |
r = resources(:template => "#{node['nginx']['dir']}/sites-available/default") | |
r.cookbook "devbox" | |
end # Originally caught an exception; we just want to throw it | |
# Overwrite the MySQL grants to allow non-localhost root logins | |
begin | |
r = resources(:template => "/etc/mysql/grants.sql") | |
r.cookbook "devbox" | |
end | |
# Add in our custom PHP settings | |
cookbook_file "/etc/php5/conf.d/10-dev-config.ini" do | |
source "php-settings.ini" | |
mode 00644 | |
end | |
php_fpm "default" do | |
action :add | |
user 'www-data' | |
group 'www-data' | |
end | |
# Set up a discard service for notifications | |
cookbook_file "/etc/xinetd.d/discard" do | |
source "discard.xinetd" | |
mode 00644 | |
notifies :restart, resources(:service => 'xinetd') | |
end | |
# Finally, create our app resources where they don't exist | |
remote_file "/vagrant/classes/config.php" do | |
source "file:///vagrant/dist/config.php" | |
mode 00644 | |
end | |
remote_file "/vagrant/adminer.php" do | |
source "file:///vagrant/dist/adminer.php" | |
mode 00644 | |
end | |
# And stuff that we need to run every time | |
execute "composer deps" do | |
user "vagrant" | |
cwd "/vagrant" | |
command "php dist/composer.phar install -o" | |
end | |
# Install the DB; do it as root so that we can use the .my.cnf file the percona recipe installs | |
bash "ensure db" do | |
user "root" | |
cwd "/vagrant" | |
code <<-EOH | |
mysql -e "DROP DATABASE IF EXISTS development; CREATE DATABASE development" | |
unxz < /vagrant/dist/db.sql.xz | mysql development | |
bin/phinx migrate -e vagrant_internal | |
touch /vagrant/dist/db.date | |
EOH | |
only_if do !File.exists?('/var/lib/mysql/development') or !File.exists?('/vagrant/dist/db.date') or (File.mtime('/vagrant/dist/db.date') < File.mtime('/vagrant/dist/db.sql.xz')) end | |
end | |
# Start ES before the population script is run | |
service "elasticsearch" do | |
action :restart | |
end | |
execute "elasticsearch indexes" do | |
user "vagrant" | |
cwd "/vagrant" | |
command "sleep 30; php dist/populate-elastic.php" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment