capistrano-chef 0.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,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-chef.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ capistrano-chef
2
+ ===============
3
+
4
+ A common use-case for applications is to have [Chef](http://www.opscode.com/chef/) configure your systems and use [Capistrano](http://capify.org/) to deploy the applications that run on them.
5
+
6
+ The Capistrano configuration has a facility to specify the roles for your application and which servers are members of those roles. Chef has its own roles. If you're using both Chef and Capistrano, you don't want to have to tell them both about which servers you'll be deploying to, especially if they change often.
7
+
8
+ capistrano-chef provides some helpers to query your Chef server from Capistrano to define these roles.
9
+
10
+ Examples
11
+ --------
12
+
13
+ A normal `deploy.rb` in an app using capistrano defines a roles like this:
14
+
15
+ role :web, 10.0.0.1, 10.0.0.2
16
+ role :db, 10.0.0.3, :primary => true
17
+
18
+ Using capistrano-chef, you can do this:
19
+
20
+ require 'capistrano/chef'
21
+ chef_role :web "roles:web"
22
+ chef_role :db, "roles:database_master", :primary => true,
23
+ :attribute => :private_ip
24
+
25
+ This defines the same roles using Chef's [search feature](http://wiki.opscode.com/display/chef/Search). Nodes are searched using the given query. The node's `ipaddress` attribute is used by default, but another (top-level) attribute can be specified in the options. The rest of the options are the same as those used by Capistrano.
26
+
27
+ Chef configuration options are loaded by [Knife](http://wiki.opscode.com/display/chef/Knifehttp://wiki.opscode.com/display/chef/Knife), looking for `.chef/knife.rb` in the current directory or one its parent directories.
28
+
29
+ License
30
+ -------
31
+
32
+ Copyright (c) 2011 Cramer Development, Inc.
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
37
+
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "capistrano/chef/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "capistrano-chef"
7
+ s.version = Capistrano::Chef::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.license = 'MIT'
10
+ s.authors = ['Nathan L Smith']
11
+ s.email = ['nlloyds@gmail.com']
12
+ s.homepage = "https://github.com/cramerdev/capistrano-chef"
13
+ s.summary = %q{Capistrano extensions for Chef integration}
14
+ s.description = %q{Allows capistrano to use Chef data for deployment}
15
+
16
+ s.rubyforge_project = "capistrano-chef"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+ s.requirements = ['capistrano ~> 2.8.0', 'chef ~> 0.10.4']
23
+ end
@@ -0,0 +1,5 @@
1
+ require 'capistrano'
2
+
3
+ class Capistrano::Chef
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,17 @@
1
+ require 'chef/knife'
2
+ require 'chef/search/query'
3
+
4
+ Capistrano::Configuration.instance.load do
5
+ Chef::Knife.new.configure_chef
6
+
7
+ # Define a role for capistrano, but instead of a list of addresses, use a chef
8
+ # query to search nodes.
9
+ def chef_role(name, query = "*:*", options = {})
10
+ # TODO: This can only get a node's top-level attributes. Make it get nested
11
+ # ones.
12
+ attr = options.delete(:attribute) || :ipaddress
13
+ nodes = Chef::Search::Query.new.search(:node, query)[0].map {|n| n[attr] }
14
+ role name, *nodes, options
15
+ nodes
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-chef
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Nathan L Smith
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-09-28 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Allows capistrano to use Chef data for deployment
17
+ email:
18
+ - nlloyds@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - Gemfile
28
+ - README.md
29
+ - Rakefile
30
+ - capistrano-chef.gemspec
31
+ - lib/capistrano/chef.rb
32
+ - lib/capistrano/chef/version.rb
33
+ homepage: https://github.com/cramerdev/capistrano-chef
34
+ licenses:
35
+ - MIT
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ requirements:
54
+ - capistrano ~> 2.8.0
55
+ - chef ~> 0.10.4
56
+ rubyforge_project: capistrano-chef
57
+ rubygems_version: 1.8.1
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Capistrano extensions for Chef integration
61
+ test_files: []
62
+