roundsman-sgonyea 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .vagrant
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@roundsman
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in roundsman.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 iain
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # Roundsman
2
+
3
+ This is an attempt to combine the powers of [Capistrano](http://capify.org) and
4
+ [chef-solo](http://wiki.opscode.com/display/chef/Chef+Solo).
5
+
6
+ The only thing you need is SSH access and a supported OS. At this time only
7
+ Ubuntu is supported.
8
+
9
+ ## Introduction
10
+
11
+ You can skip this if you already know about Capistrano and Chef.
12
+
13
+ Installing servers can be tedious work. Keeping your configuration in sync can
14
+ be hard too. Chef is an excellent tool for managing this. It can provision your
15
+ server from scratch. It can also be run again and again to check and update
16
+ your configuration if needed.
17
+
18
+ Capistrano is an excellent tool for deployment. It can deploy your code on
19
+ multiple machines, with clever defaults, limited downtime and the ability to
20
+ quickly roll back your deployment if something has gone wrong.
21
+
22
+ Roundsman aims to integrate Capistrano and Chef. This means that with every
23
+ deploy, it can check and update your configuration if needed. Are you using a
24
+ new version of Ruby in your next release? It will automatically install when
25
+ you deploy! Adding a new machine to your cluster? No problem! Roundsman will go
26
+ from a bare bones Linux machine to a working server in minutes!
27
+
28
+ Before you can use Roundsman, you need to know how to use Capistrano and how to
29
+ write Chef recipes. Here are some resources you might want to check out:
30
+
31
+ * [Capistrano's homepage](http://capify.org)
32
+ * [Opscode, the company behind Chef](http://www.opscode.com)
33
+ * [The wiki page on Chef Solo](http://wiki.opscode.com/display/chef/Chef+Solo)
34
+ * [The wiki page on creating Chef recipes](http://wiki.opscode.com/display/chef/Resources)
35
+ * [Railscast on Chef Solo](http://railscasts.com/episodes/339-chef-solo-basics) (paid)
36
+ * [Railscast on Capistrano Tasks](http://railscasts.com/episodes/133-capistrano-tasks-revised)
37
+ * [Railscast on digging deeper into Capistrano](http://railscasts.com/episodes/337-capistrano-recipes) (paid)
38
+
39
+ Feeling comfortable you can tackle deploying your application with Capistrano
40
+ and Chef? Now you can use Roundsman to combine them.
41
+
42
+ ## Installing
43
+
44
+ Roundsman runs on Ruby 1.8.7 and above.
45
+
46
+ If you're using Bundler, you can add Roundsman to your Gemfile:
47
+
48
+ ``` ruby
49
+ # Gemfile
50
+
51
+ gem 'roundsman', :require => false
52
+ ```
53
+
54
+ Run `bundle install` to get it.
55
+
56
+ If you're not using Bundler, you can install Roundsman by hand:
57
+
58
+ ``` bash
59
+ $ gem install roundsman
60
+ ```
61
+
62
+ And "capify" your project:
63
+
64
+ ``` bash
65
+ $ capify .
66
+ ```
67
+
68
+ Next, load Roundsman in `Capfile`
69
+
70
+ ``` ruby
71
+ # Capfile
72
+
73
+ require 'roundsman/capistrano'
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ By default, Roundsman assumes you put your Chef cookbooks inside
79
+ `config/cookbooks`. If you don't like this, see the
80
+ [Configuration](#Configuration) chapter. But here we're going to use that.
81
+
82
+ I'm also going to assume that you put all Capistano configuration inside
83
+ `config/deploy.rb`. When you have a lot of configuration or use the multistage
84
+ extension, you might want to place it elsewhere.
85
+
86
+ After configuring Capistrano and writing and downloading Chef recipes, you can
87
+ hook them up, with a Capistrano hook. Simply provide provide a run list. Let's
88
+ say you want to run the default recipe of your own cookbook, called `main`.
89
+
90
+ ``` ruby
91
+ # config/deploy.rb
92
+
93
+ before "deploy:update_code" do
94
+ roundsman.run_list "recipe[main]"
95
+ end
96
+ ```
97
+
98
+ I'm hooking it up before the `update_code` command, and not before `deploy` so
99
+ it will also run when running `cap deploy:migrations`.
100
+
101
+ Setting up a webserver usually requires that you have the code already there;
102
+ otherwise restarting nginx or Apache will fail, because it cannot find your
103
+ application yet. To remedy that you can make another recipe that will configure
104
+ your webserver and have it run after deploying your new code:
105
+
106
+ ``` ruby
107
+ # config/deploy.rb
108
+
109
+ after "deploy:create_symlink" do
110
+ roundsman.run_list "recipe[main::webserver]"
111
+ end
112
+ ```
113
+
114
+ If you want a recipe to only run on a specific role, you can do so like this:
115
+
116
+ ``` ruby
117
+ # config/deploy.rb
118
+
119
+ namespace :install do
120
+ task :postgres, :roles => [:db] do
121
+ roundsman.run_list "recipe[main::postgres]"
122
+ end
123
+ end
124
+
125
+ before "deploy:update_code", "install:postgres"
126
+ ```
127
+
128
+ ## Configuration
129
+
130
+ By default, Roundsman will make a lot of Capistrano's configuration available to chef.
131
+
132
+ So, you might have these settings:
133
+
134
+ ``` ruby
135
+ # config/deploy.rb
136
+
137
+ set :application, "my-awesome-blog"
138
+ set :rails_env, "production"
139
+ set :deploy_to, "/var/www/#{application}-#{rails_env}"
140
+ set :user, "deployer"
141
+ ```
142
+
143
+ Here's how you can use them inside your recipes:
144
+
145
+ ``` ruby
146
+ # config/cookbooks/main/recipes/default.rb
147
+
148
+ directory File.join(node[:deploy_to], "uploads") do
149
+ owner node[:user]
150
+ owner node[:user]
151
+ recursive true
152
+ end
153
+ ```
154
+
155
+ Every configuration option from Capistrano is available in Chef. If your using
156
+ the [passenger_apache2](https://github.com/opscode-cookbooks/passenger_apache2)
157
+ cookbook for example, you can set the attributes like this:
158
+
159
+ ``` ruby
160
+ # config/deploy.rb
161
+
162
+ set :passenger, :version => "3.0.12", :max_pool_size => 4
163
+ ```
164
+
165
+ There are also a set of configuration options for Roundsman itself. They all
166
+ have sensible defaults, but you can override them if needed. To read all the
167
+ default configuration:
168
+
169
+ ``` bash
170
+ $ cap roundsman:configuration
171
+ ```
172
+
173
+
174
+ You can also perform a lot of tasks by hand if you need to. Here's how to get
175
+ information:
176
+
177
+ ``` bash
178
+ $ cap --tasks roundsman
179
+ ```
180
+
181
+ To get more information, use the `--explain` flag and specify a task name, like
182
+ this:
183
+
184
+ ``` bash
185
+ $ cap --explain roundsman:install_ruby
186
+ ```
187
+
188
+ ## How does it work?
189
+
190
+ What Roundsman does is this:
191
+
192
+ It will determine if you have the right version of Ruby installed. Your machine
193
+ might already have an older version of Ruby installed, so if it needs to, it
194
+ will use [ruby-build](https://github.com/sstephenson/ruby-build) to install the
195
+ version of Ruby you need for your application.
196
+
197
+ Then, it will install check the version of chef-solo and install or upgrade as
198
+ needed.
199
+
200
+ It will then copy over the cookbooks from your local machine to your deployment
201
+ machine. This means that you don't need to commit every change while your still
202
+ working on it.
203
+
204
+ It will create your node.json file based upon your Capistrano configuration and
205
+ run the recipes needed.
206
+
207
+ This is all done in Capistrano hooks, using Capistrano methods like `run`, so
208
+ you can determine when and how your recipes are run.
209
+
210
+ ## Tips
211
+
212
+ ### Colors
213
+
214
+ Capistrano and Chef both give a lot of output. Check out
215
+ [capistrano_colors](https://github.com/stjernstrom/capistrano_colors)
216
+ to colorize your output for better readability.
217
+
218
+ ### Vagrant
219
+
220
+ If you want to test out your configuration locally, you should take a look at
221
+ [Vagrant](http://vagrantup.com). It makes managing a VirtualBox a breeze. You
222
+ can even create a stage just for Vagrant with the Capistrano multistage
223
+ extension.
224
+
225
+ ## Contributing
226
+
227
+ If you want to help out, please! Create an issue or do a pull request and I
228
+ will take a look at it.
229
+
230
+ To get this project up and running, make sure you have VirtualBox, because we
231
+ use vagrant. Then all you need to do is:
232
+
233
+ ``` bash
234
+ bundle install
235
+ rake
236
+ ```
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+
5
+ namespace :test do
6
+
7
+ desc "Run integration test for Ubuntu 10.04 LTE"
8
+ task :lucid do
9
+ result = system "cd test/ubuntu-lucid && ./test.sh"
10
+ exit 1 unless result
11
+ end
12
+
13
+ task :all => [ :lucid ]
14
+
15
+ end
16
+ task :test => "test:all"
17
+
18
+ task :default => :test
@@ -0,0 +1,298 @@
1
+ require 'json'
2
+ require 'tempfile'
3
+
4
+ ::Capistrano::Configuration.instance(:must_exist).load do
5
+
6
+ namespace :roundsman do
7
+
8
+ def run_list(*recipes)
9
+ if recipes.any?
10
+ set :run_list, recipes
11
+ install_ruby
12
+ run_chef
13
+ else
14
+ Array(fetch(:run_list))
15
+ end
16
+ end
17
+
18
+ def set_default(name, *args, &block)
19
+ @_defaults ||= []
20
+ @_overridden_defaults ||= []
21
+ @_defaults << name
22
+ if exists?(name)
23
+ @_overridden_defaults << name
24
+ else
25
+ set(name, *args, &block)
26
+ end
27
+ end
28
+
29
+ def roundsman_working_dir(*path)
30
+ ensure_roundsman_working_dir
31
+ File.join(fetch(:roundsman_working_dir), *path)
32
+ end
33
+
34
+ def sudo(command, *args)
35
+ run "#{top.sudo} #{command}", *args
36
+ end
37
+
38
+ def run(*args)
39
+ if fetch(:stream_roundsman_output)
40
+ top.stream *args
41
+ else
42
+ top.run *args
43
+ end
44
+ end
45
+
46
+ set_default :roundsman_working_dir, "/tmp/roundsman"
47
+ set_default :stream_roundsman_output, true
48
+ set_default(:roundsman_user) { fetch(:user) { capture('whoami').strip } }
49
+ set_default :debug_chef, false
50
+ set_default :package_manager, 'apt-get'
51
+
52
+ desc "Lists configuration"
53
+ task :configuration do
54
+ @_defaults.sort.each do |name|
55
+ display_name = ":#{name},".ljust(30)
56
+ if variables[name].is_a?(Proc)
57
+ value = "<block>"
58
+ else
59
+ value = fetch(name).inspect
60
+ value = "#{value[0..40]}... (truncated)" if value.length > 40
61
+ end
62
+ overridden = @_overridden_defaults.include?(name) ? "(overridden)" : ""
63
+ puts "set #{display_name} #{value} #{overridden}"
64
+ end
65
+ end
66
+
67
+ desc "Prepares the server for chef"
68
+ task :install_ruby do
69
+ install.default
70
+ end
71
+
72
+ desc "Runs chef"
73
+ task :run_chef do
74
+ chef.default
75
+ end
76
+
77
+ def ensure_roundsman_working_dir
78
+ unless @ensured_roundsman_working_dir
79
+ run "mkdir -p #{fetch(:roundsman_working_dir)}/cache"
80
+ sudo "chown -R #{fetch(:roundsman_user)} #{fetch(:roundsman_working_dir)}"
81
+ @ensured_roundsman_working_dir = true
82
+ end
83
+ end
84
+
85
+
86
+ namespace :install do
87
+
88
+ set_default :ruby_version, "1.9.3-p194"
89
+ set_default :care_about_ruby_version, true
90
+ set_default :ruby_install_dir, "/usr/local"
91
+
92
+ set_default :ruby_dependencies do
93
+ %w(git-core curl build-essential bison openssl
94
+ libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev
95
+ libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
96
+ vim wget tree)
97
+ end
98
+
99
+ set_default :ruby_install_script do
100
+ %Q{
101
+ set -e
102
+ cd #{roundsman_working_dir}
103
+ rm -rf ruby-build
104
+ git clone -q https://github.com/sstephenson/ruby-build.git
105
+ cd ruby-build
106
+ ./install.sh
107
+ CONFIGURE_OPTS='--disable-install-rdoc' ruby-build #{fetch(:ruby_version)} #{fetch(:ruby_install_dir)}
108
+ }
109
+ end
110
+
111
+ task :default, :except => { :no_release => true } do
112
+ if install_ruby?
113
+ dependencies
114
+ ruby
115
+ end
116
+ end
117
+
118
+ desc "Installs ruby."
119
+ task :ruby, :except => { :no_release => true } do
120
+ put fetch(:ruby_install_script), roundsman_working_dir("install_ruby.sh"), :via => :scp
121
+ sudo "bash #{roundsman_working_dir("install_ruby.sh")}"
122
+ end
123
+
124
+ desc "Installs the dependencies needed for Ruby"
125
+ task :dependencies, :except => { :no_release => true } do
126
+ ensure_supported_distro
127
+ sudo "#{fetch(:package_manager)} -yq update"
128
+ sudo "#{fetch(:package_manager)} -yq install #{fetch(:ruby_dependencies).join(' ')}"
129
+ end
130
+
131
+ desc "Checks if the ruby version installed matches the version specified"
132
+ task :check_ruby_version do
133
+ abort if install_ruby?
134
+ end
135
+
136
+ def distribution
137
+ @distribution ||= capture("cat /etc/issue").strip
138
+ end
139
+
140
+ def ensure_supported_distro
141
+ unless @ensured_supported_distro
142
+ logger.info "Using Linux distribution #{distribution}"
143
+ abort "This distribution is not (yet) supported." unless distribution.include?("Ubuntu")
144
+ @ensured_supported_distro = true
145
+ end
146
+ end
147
+
148
+ def install_ruby?
149
+ installed_version = capture("ruby --version || true").strip
150
+ if installed_version.include?("not found")
151
+ logger.info "No version of Ruby could be found."
152
+ return true
153
+ end
154
+ required_version = fetch(:ruby_version).gsub("-", "")
155
+ if installed_version.include?(required_version)
156
+ if fetch(:care_about_ruby_version)
157
+ logger.info "Ruby #{installed_version} matches the required version: #{required_version}."
158
+ return false
159
+ else
160
+ logger.info "Already installed Ruby #{installed_version}, not #{required_version}. Set :care_about_ruby_version if you want to fix this."
161
+ return false
162
+ end
163
+ else
164
+ logger.info "Ruby version mismatch. Installed version: #{installed_version}, required is #{required_version}"
165
+ return true
166
+ end
167
+ end
168
+
169
+ end
170
+
171
+ namespace :chef do
172
+
173
+ set_default :chef_version, "~> 0.10.8"
174
+ set_default :cookbooks_directory, ["config/cookbooks"]
175
+ set_default :copyfile_disable, false
176
+ set_default :filter_sensitive_settings, [ /password/, /filter_sensitive_settings/ ]
177
+
178
+ task :default, :except => { :no_release => true } do
179
+ ensure_cookbooks_exists
180
+ prepare_chef
181
+ chef_solo
182
+ end
183
+
184
+ desc "Generates the config and copies over the cookbooks to the server"
185
+ task :prepare_chef, :except => { :no_release => true } do
186
+ install if install_chef?
187
+ ensure_cookbooks_exists
188
+ generate_config
189
+ generate_attributes
190
+ copy_cookbooks
191
+ end
192
+
193
+ desc "Installs chef"
194
+ task :install, :except => { :no_release => true } do
195
+ sudo "gem uninstall -xaI chef || true"
196
+ sudo "gem install chef -v #{fetch(:chef_version).inspect} --quiet --no-ri --no-rdoc"
197
+ sudo "gem install ruby-shadow --quiet --no-ri --no-rdoc"
198
+ end
199
+
200
+ desc "Runs the existing chef configuration"
201
+ task :chef_solo, :except => { :no_release => true } do
202
+ logger.info "Now running #{fetch(:run_list).join(', ')}"
203
+ sudo "chef-solo -c #{roundsman_working_dir("solo.rb")} -j #{roundsman_working_dir("solo.json")}#{' -l debug' if fetch(:debug_chef)}"
204
+ end
205
+
206
+ def ensure_cookbooks_exists
207
+ abort "You must specify at least one recipe when running roundsman.chef" if fetch(:run_list, []).empty?
208
+ abort "No cookbooks found in #{fetch(:cookbooks_directory).inspect}" if cookbooks_paths.empty?
209
+ end
210
+
211
+ def cookbooks_paths
212
+ Array(fetch(:cookbook_path)).select { |path| File.exist?(path) }
213
+ end
214
+
215
+ def roles_path
216
+ fetch(:role_path)
217
+ end
218
+
219
+ def data_bags_path
220
+ fetch(:data_bag_path)
221
+ end
222
+
223
+ def install_chef?
224
+ required_version = fetch(:chef_version).inspect
225
+ output = capture("gem list -i -v #{required_version} || true").strip
226
+ output == "false"
227
+ end
228
+
229
+ def generate_config
230
+ cookbook_string = cookbooks_paths.map { |c| "File.join(root, #{c.to_s.inspect})" }.join(', ')
231
+ role_string = "File.join(root, #{roles_path.to_s.inspect})" if roles_path
232
+ data_bag_string = "File.join(root, #{data_bags_path.to_s.inspect})" if data_bags_path
233
+ solo_rb = <<-RUBY
234
+ root = File.expand_path(File.dirname(__FILE__))
235
+ file_cache_path File.join(root, "cache")
236
+ cookbook_path [ #{cookbook_string} ]
237
+ RUBY
238
+
239
+ solo_rb << "role_path #{role_string}\n" if role_string
240
+ solo_rb << "data_bag_path #{data_bag_string}\n" if data_bag_string
241
+
242
+ put solo_rb, roundsman_working_dir("solo.rb"), :via => :scp
243
+ end
244
+
245
+ def generate_attributes
246
+ attrs = remove_procs_from_hash variables.dup
247
+
248
+ remove_attrs = fetch(:roundsman_skip_attrs)
249
+ attrs.delete(*remove_attrs) if remove_attrs
250
+
251
+ put attrs.to_json, roundsman_working_dir("solo.json"), :via => :scp
252
+ end
253
+
254
+ # Recursively removes procs from hashes. Procs can exist because you specified them like this:
255
+ #
256
+ # set(:root_password) { Capistrano::CLI.password_prompt("Root password: ") }
257
+ def remove_procs_from_hash(hash)
258
+ new_hash = {}
259
+ hash.each do |key, value|
260
+ next if fetch(:filter_sensitive_settings).find { |regex| regex.match(key) }
261
+ real_value = if value.respond_to?(:call)
262
+ begin
263
+ value.call
264
+ rescue ::Capistrano::CommandError => e
265
+ logger.debug "Could not get the value of #{key}: #{e.message}"
266
+ nil
267
+ end
268
+ else
269
+ value
270
+ end
271
+
272
+ if real_value.is_a?(Hash)
273
+ real_value = remove_procs_from_hash(real_value)
274
+ end
275
+ if real_value && !real_value.class.to_s.include?("Capistrano") # skip capistrano tasks
276
+ new_hash[key] = real_value
277
+ end
278
+ end
279
+ new_hash
280
+ end
281
+
282
+ def copy_cookbooks
283
+ tar_file = Tempfile.new("cookbooks.tar")
284
+ begin
285
+ tar_file.close
286
+ env_vars = fetch(:copyfile_disable) && RUBY_PLATFORM.downcase.include?('darwin') ? "COPYFILE_DISABLE=true" : ""
287
+ system "#{env_vars} tar -cjf #{tar_file.path} #{cookbooks_paths.join(' ')}"
288
+ upload tar_file.path, roundsman_working_dir("cookbooks.tar"), :via => :scp
289
+ run "cd #{roundsman_working_dir} && tar -xjf cookbooks.tar"
290
+ ensure
291
+ tar_file.unlink
292
+ end
293
+ end
294
+
295
+ end
296
+
297
+ end
298
+ end
@@ -0,0 +1,3 @@
1
+ module Roundsman
2
+ VERSION = "0.1.0.1"
3
+ end
data/lib/roundsman.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "roundsman/version"
2
+
3
+ module Roundsman
4
+ end
data/roundsman.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/roundsman/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["iain"]
6
+ gem.email = ["iain@iain.nl"]
7
+ gem.description = %q{Combine the awesome powers of Capistrano and Chef. The only thing you need is SSH access.}
8
+ gem.summary = %q{Various Capistrano tasks for bootstrapping servers with Chef}
9
+ gem.homepage = "https://github.com/iain/roundsman"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "roundsman-sgonyea"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Roundsman::VERSION
17
+
18
+ gem.add_runtime_dependency "capistrano", "~> 2.12"
19
+ gem.add_development_dependency "vagrant", "~> 1.0"
20
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # These lines are part of the default Capfile
4
+ load 'deploy'
5
+ load 'config/deploy'
6
+
7
+ # These lines are to get Roundsman loaded for the test
8
+ require 'roundsman/capistrano'
@@ -0,0 +1,5 @@
1
+ namespace :db do
2
+ task :migrate do
3
+ puts "rake db:migrate ran"
4
+ end
5
+ end
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "lucid32"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://files.vagrantup.com/lucid32.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file base.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "base.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end
@@ -0,0 +1 @@
1
+ gem_package "bundler"
@@ -0,0 +1,20 @@
1
+ set :application, "my-awesome-blog"
2
+
3
+ set :repository, "."
4
+ set :scm, :none # not recommended in production
5
+ set :deploy_via, :copy
6
+
7
+ server "192.168.33.10", :web, :app, :db, :primary => true
8
+
9
+ set :user, "vagrant"
10
+ set :password, "vagrant" # not recommended in production
11
+
12
+ set :deploy_to, "/home/#{user}/#{application}"
13
+
14
+ set :use_sudo, false
15
+ default_run_options[:pty] = true
16
+
17
+ before "deploy:cold" do
18
+ deploy.setup
19
+ roundsman.run_list "recipe[main::cold]"
20
+ end
@@ -0,0 +1,4 @@
1
+ set -e
2
+
3
+ bundle exec vagrant up
4
+ bundle exec cap deploy:cold
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roundsman-sgonyea
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - iain
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.12'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.12'
30
+ - !ruby/object:Gem::Dependency
31
+ name: vagrant
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ description: Combine the awesome powers of Capistrano and Chef. The only thing you
47
+ need is SSH access.
48
+ email:
49
+ - iain@iain.nl
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rvmrc
56
+ - Gemfile
57
+ - MIT-LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/roundsman.rb
61
+ - lib/roundsman/capistrano.rb
62
+ - lib/roundsman/version.rb
63
+ - roundsman.gemspec
64
+ - test/ubuntu-lucid/Capfile
65
+ - test/ubuntu-lucid/Rakefile
66
+ - test/ubuntu-lucid/Vagrantfile
67
+ - test/ubuntu-lucid/config/cookbooks/main/recipes/cold.rb
68
+ - test/ubuntu-lucid/config/deploy.rb
69
+ - test/ubuntu-lucid/test.sh
70
+ homepage: https://github.com/iain/roundsman
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 1.8.23
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Various Capistrano tasks for bootstrapping servers with Chef
94
+ test_files:
95
+ - test/ubuntu-lucid/Capfile
96
+ - test/ubuntu-lucid/Rakefile
97
+ - test/ubuntu-lucid/Vagrantfile
98
+ - test/ubuntu-lucid/config/cookbooks/main/recipes/cold.rb
99
+ - test/ubuntu-lucid/config/deploy.rb
100
+ - test/ubuntu-lucid/test.sh