winton-cookbook 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/recipes/rails.rb ADDED
@@ -0,0 +1,65 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :rails do
4
+ namespace :config do
5
+ desc "Copies all files in cookbook/rails to shared config"
6
+ task :default, :roles => :app do
7
+ run "mkdir -p #{shared_path}/config"
8
+ Dir[File.expand_path('../config/rails/*', File.dirname(__FILE__))].each do |f|
9
+ upload_from_erb "#{shared_path}/config/#{File.basename(f, '.erb')}", binding, :folder => 'rails'
10
+ end
11
+ end
12
+
13
+ desc "Copies yml files in the shared config folder into our app config"
14
+ task :to_app, :roles => :app do
15
+ run "cp -Rf #{shared_path}/config/* #{release_path}/config"
16
+ end
17
+
18
+ desc "Configure asset_packager"
19
+ task :asset_packager do
20
+ run "source ~/.bash_profile && cd #{release_path} && rake RAILS_ENV=production asset:packager:build_all"
21
+ end
22
+
23
+ desc "Configure attachment_fu"
24
+ task :attachment_fu, :roles => :app do
25
+ run_each [
26
+ "mkdir -p #{shared_path}/media",
27
+ "ln -sf #{shared_path}/media #{release_path}/public/media"
28
+ ]
29
+ sudo_each [
30
+ "mkdir -p #{release_path}/tmp/attachment_fu",
31
+ "chown -R #{user} #{release_path}/tmp/attachment_fu"
32
+ ]
33
+ end
34
+
35
+ namespace :ultrasphinx do
36
+ desc "Configures ultrasphinx"
37
+ task :default, :roles => :app do
38
+ sudo "cd #{release_path} && rake RAILS_ENV=production ultrasphinx:configure"
39
+ end
40
+
41
+ desc "Stop ultrasphinx"
42
+ task :stop, :roles => :app do
43
+ sudo "cd #{release_path} && rake RAILS_ENV=production ultrasphinx:daemon:stop"
44
+ end
45
+
46
+ desc "Start ultrasphinx"
47
+ task :start, :roles => :app do
48
+ sudo "cd #{release_path} && rake RAILS_ENV=production ultrasphinx:daemon:start"
49
+ end
50
+
51
+ desc "Restart ultrasphinx"
52
+ task :restart, :roles => :app do
53
+ rails.config.ultrasphinx.stop
54
+ rails.config.ultrasphinx.start
55
+ end
56
+ end
57
+ end
58
+
59
+ desc "Intialize Git submodules"
60
+ task :setup_git, :roles => :app do
61
+ run "cd #{release_path}; git submodule init; git submodule update"
62
+ end
63
+ end
64
+
65
+ end
data/recipes/ssh.rb ADDED
@@ -0,0 +1,64 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ namespace :ssh do
4
+ desc 'Generate ssh keys and upload to server'
5
+ task :setup do
6
+ ssh.create_keys
7
+ ssh.upload_keys
8
+ end
9
+
10
+ desc "Creates an rsa ssh key pair in your ~/.ssh folder"
11
+ task :create_keys do
12
+ question = [
13
+ "This task generates a rsa ssh key pair in your ~/.ssh folder.",
14
+ "OK?"
15
+ ]
16
+ system('ssh-keygen -t rsa') if yes(question)
17
+ end
18
+
19
+ desc "Creates an rsa ssh key pair in the server's ~/.ssh folder"
20
+ task :create_server_keys do
21
+ question = [
22
+ "This task generates a rsa ssh key pair in the server's ~/.ssh folder and displays the public key.",
23
+ "OK?"
24
+ ]
25
+ if yes(question)
26
+ usr = ask "Create ssh keys for which user? (default: #{user})", user
27
+ pass = ask "Enter a password for this key:"
28
+
29
+ sudo_each [
30
+ "ssh-keygen -t rsa -N '#{pass}' -q -f /home/#{usr}/.ssh/id_rsa",
31
+ "chmod 0700 /home/#{usr}/.ssh",
32
+ "chown -R #{usr} /home/#{usr}/.ssh"
33
+ ]
34
+ sudo_puts "tail -1 /home/#{usr}/.ssh/id_rsa.pub"
35
+ end
36
+ end
37
+
38
+ desc "Copies contents of ssh public keys into authorized_keys file"
39
+ task :upload_keys do
40
+ question = [
41
+ "This task copies all of your public keys in ~/.ssh to the server's authorized_keys.",
42
+ "OK?"
43
+ ]
44
+ if yes(question)
45
+ usr = ask "Upload ssh public keys to which user? (default: #{user})", user
46
+ keys = ask "Press enter to copy all public keys (~/.ssh/*.pub), or paste a key: ", get_ssh_keys
47
+
48
+ if k.empty?
49
+ ssh.setup if yes("No keys found. Generate ssh keys now?")
50
+ else
51
+ sudo_each [
52
+ "mkdir /home/#{usr}/.ssh",
53
+ "touch /home/#{usr}/.ssh/authorized_keys",
54
+ "echo \"#{keys}\" >> /home/#{usr}/.ssh/authorized_keys",
55
+ "chmod 0700 /home/#{usr}/.ssh",
56
+ "chmod 0600 /home/#{usr}/.ssh/authorized_keys",
57
+ "chown -R #{usr} /home/#{usr}/.ssh",
58
+ ]
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ end
data/recipes/stage.rb ADDED
@@ -0,0 +1,34 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ desc 'Set the target stage to staging'
4
+ task :staging do
5
+ set :stage, :staging
6
+ end
7
+
8
+ desc 'Set the target stage to test'
9
+ task :testing do
10
+ set :stage, :test
11
+ end
12
+
13
+ # None of this works in a namespace
14
+ desc 'Set up stage-dependent properties'
15
+ task :setup_stage do
16
+ set :base_dir, "#{cookbook[:base_dir]}/#{stage}"
17
+ set :deploy_to, "#{base_dir}/#{application}"
18
+
19
+ set :db_table, application + (stage == :staging ? "_#{stage}" : '')
20
+ set :mongrel_port, cookbook[:mongrel_port] + production_mongrels if stage == :staging
21
+
22
+ set :domain, cookbook[stage][:domain]
23
+ set :domains, (cookbook[stage][:other_domains] || []) + [ domain ]
24
+ set :branch, cookbook[stage][:branch] || 'master'
25
+ set :mongrels, cookbook[stage][:mongrels]
26
+ set :auth_user, cookbook[stage][:auth_user]
27
+ set :auth_pass, cookbook[stage][:auth_pass]
28
+
29
+ role :app, domain
30
+ role :web, domain
31
+ role :db, domain, :primary => true
32
+ end
33
+
34
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: winton-cookbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Winton Welsh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-16 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Turns a fresh Debian server into an autonomous Nginx/Rails/PHP stack using purely Capistrano
17
+ email: mail@wintoni.us
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - config/log
26
+ - config/log/rotate.conf.erb
27
+ - config/php
28
+ - config/php/php-fastcgi.erb
29
+ - config/php/init-fastcgi.erb
30
+ - config/php/nginx.vhost.erb
31
+ - config/monit
32
+ - config/monit/nginx.vhost.erb
33
+ - config/monit/monitrc.erb
34
+ - config/monit/mongrel.erb
35
+ - config/monit/monit.erb
36
+ - config/nginx
37
+ - config/nginx/nginx.erb
38
+ - config/nginx/nginx.conf.erb
39
+ - config/mysql
40
+ - config/mysql/my.cnf.erb
41
+ - config/rails
42
+ - config/rails/database.yml.erb
43
+ - config/debian
44
+ - config/debian/sshd_config.erb
45
+ - config/debian/iptables.rules.erb
46
+ - config/debian/bash_profile.erb
47
+ - config/debian/locale.gen.erb
48
+ - config/mongrel
49
+ - config/mongrel/nginx.vhost.erb
50
+ - config/mongrel/mongrel.yml.erb
51
+ - cookbook.rb
52
+ - cookbook_helpers.rb
53
+ - deploy.rb.example
54
+ - MIT-LICENSE
55
+ - README.markdown
56
+ - recipes/debian.rb
57
+ - recipes/mongrel.rb
58
+ - recipes/deploy.rb
59
+ - recipes/rails.rb
60
+ - recipes/monit.rb
61
+ - recipes/gems.rb
62
+ - recipes/log.rb
63
+ - recipes/php.rb
64
+ - recipes/ssh.rb
65
+ - recipes/stage.rb
66
+ - recipes/nginx.rb
67
+ - recipes/mysql.rb
68
+ has_rdoc: false
69
+ homepage: http://github.com/winton/cookbook
70
+ post_install_message:
71
+ rdoc_options: []
72
+
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ version:
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.2.0
91
+ signing_key:
92
+ specification_version: 2
93
+ summary: Turns a fresh Debian server into an autonomous Nginx/Rails/PHP stack using purely Capistrano
94
+ test_files: []
95
+