capistrano-provisioning 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/capistrano-provisioning.gemspec +3 -2
- data/lib/capistrano-provisioning/user.rb +29 -17
- data/pkg/capistrano-provisioning-0.0.4.gem +0 -0
- data/spec/recipes_spec.rb +39 -8
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
@@ -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.
|
8
|
+
s.version = "0.0.6"
|
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-
|
12
|
+
s.date = %q{2010-06-29}
|
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 = [
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"pkg/capistrano-provisioning-0.0.0.gem",
|
32
32
|
"pkg/capistrano-provisioning-0.0.1.gem",
|
33
33
|
"pkg/capistrano-provisioning-0.0.3.gem",
|
34
|
+
"pkg/capistrano-provisioning-0.0.4.gem",
|
34
35
|
"spec/cluster_spec.rb",
|
35
36
|
"spec/namespaces_spec.rb",
|
36
37
|
"spec/recipes_spec.rb",
|
@@ -13,12 +13,15 @@ module CapistranoProvisioning
|
|
13
13
|
abort "Aborting - Cannot install user #{self.name} as no server specified" unless opts[:server]
|
14
14
|
abort "Aborting - Could not find key for #{self.name} at #{local_key_file_path}" unless key
|
15
15
|
|
16
|
-
|
16
|
+
self.server = opts[:server]
|
17
17
|
|
18
|
-
self.
|
19
|
-
|
20
|
-
self.
|
21
|
-
self.
|
18
|
+
logger.debug "installing #{self.name} on #{self.server}"
|
19
|
+
|
20
|
+
self.create_account_on_server unless self.account_exists?
|
21
|
+
self.create_ssh_config_directory
|
22
|
+
self.update_authorized_keys
|
23
|
+
self.set_ssh_config_permissions
|
24
|
+
self.add_account_to_groups
|
22
25
|
end
|
23
26
|
|
24
27
|
def groups
|
@@ -26,7 +29,9 @@ module CapistranoProvisioning
|
|
26
29
|
end
|
27
30
|
|
28
31
|
protected
|
29
|
-
|
32
|
+
attr_accessor :server
|
33
|
+
|
34
|
+
def account_exists?(server = self.server)
|
30
35
|
begin
|
31
36
|
if capture("id #{self.name}", :hosts => server)
|
32
37
|
true
|
@@ -43,35 +48,36 @@ module CapistranoProvisioning
|
|
43
48
|
File.read(local_key_file_path) if File.exists?(local_key_file_path)
|
44
49
|
end
|
45
50
|
|
46
|
-
def create_account_on_server(server)
|
51
|
+
def create_account_on_server(server = self.server)
|
47
52
|
run "#{sudo} /usr/sbin/useradd -m #{name}", :pty => true, :hosts => server
|
48
53
|
end
|
49
54
|
|
50
|
-
def add_account_to_groups(server)
|
55
|
+
def add_account_to_groups(server = self.server)
|
51
56
|
self.groups.each do |group|
|
52
57
|
run "#{sudo} /usr/sbin/usermod -a -G#{group} #{self.name}", :pty => true, :hosts => server
|
53
58
|
end
|
54
59
|
end
|
55
60
|
|
56
|
-
def create_ssh_config_directory(server)
|
61
|
+
def create_ssh_config_directory(server = self.server)
|
57
62
|
# Actual dirt
|
58
63
|
commands = <<-COMMANDS
|
59
64
|
sudo su root -c 'if [ ! -d #{ssh_config_directory_path} ]; then
|
60
65
|
sudo mkdir #{ssh_config_directory_path};
|
61
66
|
fi';
|
62
|
-
#{sudo} chown #{name} #{ssh_config_directory_path} &&
|
63
|
-
#{sudo} chmod 700 #{ssh_config_directory_path}
|
64
67
|
COMMANDS
|
65
68
|
|
66
69
|
run commands, :pty => true, :hosts => server
|
67
70
|
end
|
68
71
|
|
69
|
-
def update_authorized_keys(server)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
def update_authorized_keys(server = self.server)
|
73
|
+
tmp_location = "/tmp/#{self.name}.pub"
|
74
|
+
put key, tmp_location
|
75
|
+
run "#{sudo} mv #{tmp_location} #{authorized_keys_file_path}", :pty => true, :hosts => server
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_ssh_config_permissions(server = self.server)
|
79
|
+
run "#{sudo} chown -R #{name} #{ssh_config_directory_path}", :pty => true, :hosts => server
|
80
|
+
run "#{sudo} chmod -R 700 #{ssh_config_directory_path}", :pty => true, :hosts => server
|
75
81
|
end
|
76
82
|
|
77
83
|
def authorized_keys_file_path
|
@@ -94,6 +100,12 @@ module CapistranoProvisioning
|
|
94
100
|
protected
|
95
101
|
# This isn't the best way to get to the run/logger stuff in this class -
|
96
102
|
# need to figure out a better way to do this, or a way to not need to.
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
def put(data, path, options={})
|
107
|
+
self.config.put(data, path, options)
|
108
|
+
end
|
97
109
|
|
98
110
|
def sudo(*parameters, &block)
|
99
111
|
self.config.sudo(*parameters, &block)
|
Binary file
|
data/spec/recipes_spec.rb
CHANGED
@@ -1,17 +1,48 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
#
|
3
|
+
# Fake a running instance of Capistrano
|
4
|
+
Capistrano::Configuration.instance = Capistrano::Configuration.new
|
5
|
+
require 'capistrano-provisioning/recipes'
|
4
6
|
|
5
|
-
describe "Recipes" do
|
7
|
+
describe "Recipes" do
|
8
|
+
let(:config) { Capistrano::Configuration.instance }
|
9
|
+
|
6
10
|
context "namespace" do
|
7
|
-
it "should create an :all task which loads all servers in that namespace"
|
11
|
+
it "should create an :all task which loads all servers in that namespace" do
|
12
|
+
pending("Currently failing due to inheritance confusion")
|
13
|
+
|
14
|
+
config.load do
|
15
|
+
namespace :test_namespace do
|
16
|
+
cluster :test_cluster, 'cluster1.example.com'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
puts config.tasks.keys.inspect.gsub("<", '<')
|
21
|
+
config.namespaces.should include(:test_namespace)
|
22
|
+
config.tasks.keys.should include(:test_namespace)
|
23
|
+
end
|
8
24
|
end
|
9
25
|
|
10
|
-
context "
|
11
|
-
it "should create a task to
|
12
|
-
|
13
|
-
|
26
|
+
context "global" do
|
27
|
+
it "should create a task to bootstrap the servers" do
|
28
|
+
config.tasks.keys.should include(:run_bootstrap)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should create a task to install users on the servers" do
|
32
|
+
config.tasks.keys.should include(:install_users)
|
33
|
+
end
|
14
34
|
|
15
|
-
it "should create a task to
|
35
|
+
it "should create a task to preview users that will be installed" do
|
36
|
+
config.tasks.keys.should include(:install_users)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "cluster definition" do
|
41
|
+
it "should create a task to set the servers" do
|
42
|
+
pending("Currently failing due to inheritance confusion")
|
43
|
+
|
44
|
+
config.cluster :test_cluster
|
45
|
+
config.tasks.keys.should include(:test_cluster)
|
46
|
+
end
|
16
47
|
end
|
17
48
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
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-
|
17
|
+
date: 2010-06-29 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- pkg/capistrano-provisioning-0.0.0.gem
|
70
70
|
- pkg/capistrano-provisioning-0.0.1.gem
|
71
71
|
- pkg/capistrano-provisioning-0.0.3.gem
|
72
|
+
- pkg/capistrano-provisioning-0.0.4.gem
|
72
73
|
- spec/cluster_spec.rb
|
73
74
|
- spec/namespaces_spec.rb
|
74
75
|
- spec/recipes_spec.rb
|