Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use chef to replace puppet. <3 <3 <3

  • Loading branch information...
commit 7edac5de6d7ecccfe4905a6f0bd9901e9ce1c561 1 parent 6ecb6cc
@SaitoWu authored
View
2  .gitignore
@@ -1,2 +1,4 @@
.vagrant
.DS_Store
+tmp
+cookbooks/*
View
15 .gitmodules
@@ -1,15 +0,0 @@
-[submodule "manifests/modules/mysql"]
- path = manifests/modules/mysql
- url = https://github.com/puppetlabs/puppetlabs-mysql.git
-[submodule "manifests/modules/rvm"]
- path = manifests/modules/rvm
- url = https://github.com/blt04/puppet-rvm.git
-[submodule "manifests/modules/mongodb"]
- path = manifests/modules/mongodb
- url = https://github.com/portertech/puppet-mongodb.git
-[submodule "manifests/modules/redis"]
- path = manifests/modules/redis
- url = https://github.com/example42/puppet-redis.git
-[submodule "manifests/modules/postgresql"]
- path = manifests/modules/postgresql
- url = https://github.com/akumria/puppet-postgresql.git
View
19 Cheffile
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#^syntax detection
+
+site 'http://community.opscode.com/api/v1'
+
+cookbook 'apt',
+ :git => 'https://github.com/opscode-cookbooks/apt.git'
+
+cookbook 'build-essential',
+ :git => 'https://github.com/opscode-cookbooks/build-essential.git'
+
+cookbook 'nginx',
+ :git => 'https://github.com/gchef/nginx-cookbook.git'
+
+cookbook 'redis',
+ :git => 'https://github.com/ctrabold/chef-redis.git'
+
+cookbook 'postgresql',
+ :git => 'https://github.com/phlipper/chef-postgresql.git'
View
44 Cheffile.lock
@@ -0,0 +1,44 @@
+GIT
+ remote: https://github.com/ctrabold/chef-redis.git
+ ref: master
+ sha: a5686a513d5912a51a4f4cb40f708a4a31cd1707
+ specs:
+ redis (0.0.4)
+
+GIT
+ remote: https://github.com/gchef/nginx-cookbook.git
+ ref: master
+ sha: 18b5176a4ec3fa54d969021b1275ef1e7a6772fc
+ specs:
+ nginx (2.7.3)
+ apt (>= 0.0.0)
+ build-essential (>= 0.0.0)
+
+GIT
+ remote: https://github.com/opscode-cookbooks/apt.git
+ ref: master
+ sha: d9011dcfc4af935a7c5b5be512f90499f08683ba
+ specs:
+ apt (1.4.9)
+
+GIT
+ remote: https://github.com/opscode-cookbooks/build-essential.git
+ ref: master
+ sha: 973f97efc279780c0f3de027bb020a1615a9f84d
+ specs:
+ build-essential (1.1.2)
+
+GIT
+ remote: https://github.com/phlipper/chef-postgresql.git
+ ref: master
+ sha: f9fb4099f0d1fc40239a7a60d3ff9e0aee06f885
+ specs:
+ postgresql (0.5.0)
+
+DEPENDENCIES
+ apt (>= 0)
+ build-essential (>= 0)
+ nginx (>= 0)
+ postgresql (>= 0)
+ redis (>= 0)
+
View
16 Vagrantfile
@@ -1,11 +1,15 @@
Vagrant::Config.run do |config|
- config.vm.box = "precise"
- config.vm.box_url = "http://files.vagrantup.com/precise32.box"
+ config.vm.box = "oneiric"
+ config.vm.box_url = "http://timhuegdon.com/vagrant-boxes/Ubuntu-11.10.box"
config.vm.forward_port 80, 8080
- config.vm.provision :puppet do |puppet|
- puppet.manifests_path = "manifests"
- puppet.manifest_file = "base.pp"
- puppet.module_path = "manifests/modules"
+ config.vm.provision :chef_solo do |chef|
+ chef.cookbooks_path = "cookbooks"
+ chef.add_recipe("apt")
+ chef.add_recipe("build-essential")
+ chef.add_recipe("nginx::source")
+ chef.add_recipe("redis::source")
+ chef.add_recipe("postgresql::client")
+ chef.add_recipe("postgresql::server")
end
end
View
87 manifests/base.pp
@@ -1,87 +0,0 @@
-# variables
-$user = { name => 'deployer', group => 'admin'}
-$ruby = { version => 'ruby-1.9.3-p194'}
-$application = { name => 'example', root => "/home/${user['name']}/example"}
-$mysql = { root_password => 'root'}
-$postgresql = { user => 'root', password => 'root'}
-$nginx = { root => "/home/${user['name']}/${application['name']}/public/index.htm", server_name => 'localhost'}
-$unicorn = { socket => "/tmp/${application['name']}/unicorn.sock"}
-
-# user
-user { $user['name']:
- managehome => true,
- ensure => present,
- shell => "/bin/bash",
- gid => $user['group'],
- home => "/home/${user['name']}"
-}
-
-# rvm ruby
-include rvm
-
-rvm::system_user { $user['name']: ; }
-
-rvm_system_ruby { $ruby['version']:
- ensure => present,
- # default_use => true;
-}
-
-rvm_gem { 'bundler':
- ensure => installed,
- ruby_version => $ruby['version'],
- require => Rvm_system_ruby[ $ruby['version'] ];
-}
-
-# mysql
-class { 'mysql::ruby': }
-class { 'mysql::server':
- config_hash => { 'root_password' => $mysql['root_password'] }
-}
-
-# postgresql
-class { 'postgresql::server':
- version => '9.1',
-}
-pg_user { $postgresql['user']:
- ensure => present,
- password => $postgresql['password'],
- createdb => true,
- createrole => true
-}
-
-# mongodb
-class { 'mongodb': }
-
-# redis
-# class { 'redis': }
-
-# unicorn
-file { "/etc/init.d/unicorn":
- mode => "755",
- ensure => "present",
- content => template('base/unicorn.sh.erb');
-}
-
-# nginx
-package { 'nginx':
- ensure => present;
-}
-
-file { "/etc/nginx/sites-enabled/default":
- ensure => absent;
-}
-
-file { "/etc/nginx/sites-enabled/${application['name']}":
- ensure => file,
- content => template('base/nginx.conf.erb'),
- require => Package['nginx'];
-}
-
-service { "nginx":
- ensure => running,
- enable => true,
- hasstatus => true,
- hasrestart => true,
- subscribe => File["/etc/nginx/sites-enabled/${application['name']}"],
- require => Package['nginx']
-}
View
21 manifests/modules/base/templates/nginx.conf.erb
@@ -1,21 +0,0 @@
-upstream unicorn {
- server unix:<%= unicorn['socket'] %> fail_timeout=0;
-}
-
-server {
- listen 80 default deferred;
- server_name <%= nginx['server_name'] %>;
- root <%= nginx['root'] %>;
- try_files $uri/index.html $uri @unicorn;
-
- location @unicorn {
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header Host $http_host;
- proxy_redirect off;
- proxy_pass http://unicorn;
- }
-
- error_page 500 502 503 504 /500.html;
- client_max_body_size 1M;
- keepalive_timeout 10;
-}
View
71 manifests/modules/base/templates/unicorn.sh.erb
@@ -1,71 +0,0 @@
-#!/bin/sh
-set -e
-# Example init script, this can be used with nginx, too,
-# since nginx and unicorn accept the same signals
-
-# Feel free to change any of the following variables for your app:
-TIMEOUT=${TIMEOUT-60}
-APP_ROOT=<%= application['root'] %>
-PID=<%= unicorn['socket'] %>
-CMD="$APP_ROOT/bin/unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
-action="$1"
-set -u
-
-old_pid="$PID.oldbin"
-
-cd $APP_ROOT || exit 1
-
-sig () {
- test -s "$PID" && kill -$1 `cat $PID`
-}
-
-oldsig () {
- test -s $old_pid && kill -$1 `cat $old_pid`
-}
-
-case $action in
-start)
- sig 0 && echo >&2 "Already running" && exit 0
- su -c "$CMD" - invest
- ;;
-stop)
- sig QUIT && exit 0
- echo >&2 "Not running"
- ;;
-force-stop)
- sig TERM && exit 0
- echo >&2 "Not running"
- ;;
-restart|reload)
- sig HUP && echo reloaded OK && exit 0
- echo >&2 "Couldn't reload, starting '$CMD' instead"
- su -c "$CMD" - invest
- ;;
-upgrade)
- if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
- then
- n=$TIMEOUT
- while test -s $old_pid && test $n -ge 0
- do
- printf '.' && sleep 1 && n=$(( $n - 1 ))
- done
- echo
-
- if test $n -lt 0 && test -s $old_pid
- then
- echo >&2 "$old_pid still exists after $TIMEOUT seconds"
- exit 1
- fi
- exit 0
- fi
- echo >&2 "Couldn't upgrade, starting '$CMD' instead"
- su -c "$CMD" - invest
- ;;
-reopen-logs)
- sig USR1
- ;;
-*)
- echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
- exit 1
- ;;
-esac
1  manifests/modules/mongodb
@@ -1 +0,0 @@
-Subproject commit 38bb8917f42be6aaa7e084820dfc5ba414218494
1  manifests/modules/mysql
@@ -1 +0,0 @@
-Subproject commit be493c3a4117ff1096b9cf39bb004406239e95fe
1  manifests/modules/postgresql
@@ -1 +0,0 @@
-Subproject commit 5400e76ad0eeb17695dee7bcb4e2013716fb5933
1  manifests/modules/redis
@@ -1 +0,0 @@
-Subproject commit a12060daf74f6dc3de7b1702194f0f6877ae5946
1  manifests/modules/rvm
@@ -1 +0,0 @@
-Subproject commit e07e606f10f408a9bf810c44ee5baaaa6fadd803
Please sign in to comment.
Something went wrong with that request. Please try again.