capistrano-provisioning 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown CHANGED
@@ -155,6 +155,12 @@ Which would mean that running:
155
155
 
156
156
  ... would add Bob, Joe and Rupert to the web cluster, with the appropriate groups.
157
157
 
158
+ To only install specific users, specify them in a hosts variable:
159
+
160
+ cap system1:web install_users USERS='bob'
161
+
162
+ This will only install bob - useful for if you're just adding one user and don't want to do a fullscale pass of all the keys. Note, though, that this user still needs to be defined within the recipe.
163
+
158
164
  #### Inheriting default users
159
165
 
160
166
  By default, namespaces do _not_ inherit default users from the namespace above. If you want this inheritance, it's easy:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{capistrano-provisioning}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sam Phillips"]
12
- s.date = %q{2010-06-29}
12
+ s.date = %q{2010-06-30}
13
13
  s.description = %q{Capistrano Provisioning is an extension to Capistrano that allows you to define clusters of servers and run provisioning tasks on them, such as installing users. It is a replacement for the fabric gem (http://rubygems.org/gems/fabric).}
14
14
  s.email = %q{sam@samdanavia.com}
15
15
  s.extra_rdoc_files = [
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  "pkg/capistrano-provisioning-0.0.1.gem",
33
33
  "pkg/capistrano-provisioning-0.0.3.gem",
34
34
  "pkg/capistrano-provisioning-0.0.4.gem",
35
+ "pkg/capistrano-provisioning-0.0.6.gem",
35
36
  "spec/cluster_spec.rb",
36
37
  "spec/namespaces_spec.rb",
37
38
  "spec/recipes_spec.rb",
@@ -13,22 +13,24 @@ module CapistranoProvisioning
13
13
  add_cluster_cap_task
14
14
  end
15
15
 
16
- def install_users
17
- ensure_users
18
-
16
+ def install_users(specified_users = [])
17
+ ensure_users
18
+
19
19
  self.servers.each do |server|
20
20
  self.users.each do |user|
21
+ next unless specified_users.empty? or specified_users.include?(user.name)
21
22
  user.install(:server => server)
22
23
  end
23
24
  end
24
25
  end
25
26
 
26
- def preview_users
27
+ def preview_users(specified_users = [])
27
28
  ensure_users
28
29
 
29
30
  self.servers.each do |server|
30
31
  puts "#{server}: "
31
32
  self.users.each do |user|
33
+ next unless specified_users.empty? or specified_users.include?(user.name)
32
34
  groups = user.groups.empty? ? '' : "(#{user.groups.join(', ')})"
33
35
  puts "\t#{user.name} #{groups}"
34
36
  end
@@ -27,14 +27,19 @@ Capistrano::Configuration.instance(:must_exist).load do
27
27
  desc "Installs the specified users on the cluster"
28
28
  task :install_users do
29
29
  @clusters.each do |cluster|
30
- cluster.install_users
30
+ cluster.install_users(user_list)
31
31
  end
32
32
  end
33
33
 
34
34
  task :preview_users do
35
35
  puts "The following users will be added: "
36
36
  @clusters.each do |cluster|
37
- cluster.preview_users
37
+ cluster.preview_users(user_list)
38
38
  end
39
39
  end
40
+
41
+ def user_list
42
+ return [] if ENV["USERS"].nil?
43
+ ENV["USERS"].split(/, ?/)
44
+ end
40
45
  end
data/spec/cluster_spec.rb CHANGED
@@ -64,19 +64,32 @@ describe CapistranoProvisioning::Cluster do
64
64
  user_names.should include('bob', 'juan')
65
65
  user_names.should_not include('sam', 'david')
66
66
  end
67
+
68
+ context "installation" do
69
+ let(:test_user) { CapistranoProvisioning::User.new(:name => 'test_user') }
70
+ let(:test_user_2) { CapistranoProvisioning::User.new(:name => 'test_user_2') }
71
+
72
+ before(:each) do
73
+ test_user.stub!(:key => 'test key')
74
+ test_user_2.stub!(:key => 'test key 2')
75
+
76
+ cluster.servers = 'host1.example.com'
77
+ cluster.add_users [test_user, test_user_2]
78
+ end
67
79
 
68
- it "should install users" do
69
- test_user, test_user_2 = user.dup, user.dup
70
-
71
- test_user.stub!(:key => 'test key')
72
- test_user.should_receive(:install)
73
-
74
- test_user_2.stub!(:key => 'test key 2')
75
- test_user_2.should_receive(:install)
76
-
77
- cluster.servers = 'host1.example.com'
78
- cluster.add_users [test_user, test_user_2]
79
- cluster.install_users
80
+ it "should install all users when no specific users are passed" do
81
+ test_user.should_receive(:install)
82
+ test_user_2.should_receive(:install)
83
+
84
+ cluster.install_users
85
+ end
86
+
87
+ it "should install only specified users when specific users are passed" do
88
+ test_user.should_receive(:install)
89
+ test_user_2.should_not_receive(:install)
90
+
91
+ cluster.install_users('test_user')
92
+ end
80
93
  end
81
94
  end
82
95
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 6
9
- version: 0.0.6
8
+ - 7
9
+ version: 0.0.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sam Phillips
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-29 00:00:00 +01:00
17
+ date: 2010-06-30 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -70,6 +70,7 @@ files:
70
70
  - pkg/capistrano-provisioning-0.0.1.gem
71
71
  - pkg/capistrano-provisioning-0.0.3.gem
72
72
  - pkg/capistrano-provisioning-0.0.4.gem
73
+ - pkg/capistrano-provisioning-0.0.6.gem
73
74
  - spec/cluster_spec.rb
74
75
  - spec/namespaces_spec.rb
75
76
  - spec/recipes_spec.rb