baptize 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/baptize/application.rb +6 -2
- data/lib/baptize/commands.rb +10 -3
- data/lib/baptize/package_definition.rb +2 -2
- data/lib/baptize/registry.rb +21 -6
- data/lib/baptize/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b34dd42ccdba0c8f9a4d9cca33a451db3f8ba485
|
4
|
+
data.tar.gz: 701640fa69056abbda8784a261a3f3f74b30719b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1a5fb55be30db16631eb64afb79c0005776e9e7c5dd3e801ea4f684d359e3b0eeca671f9dedbc32cbff250dcc1e39c6a79266283ff7c600e7808fdee408d55a
|
7
|
+
data.tar.gz: 1f00a6870ea94bc510c0fc499a851126737ad4d99150d12b30d13336b22fe7cf16d87bdaddc28043629252a329862a4e465e8c5cc404d85eda6fcb3b7740cf0b
|
data/lib/baptize/application.rb
CHANGED
@@ -14,6 +14,10 @@ module Baptize
|
|
14
14
|
@name, @description, @block = name.to_sym, description, block
|
15
15
|
end
|
16
16
|
|
17
|
+
def name_with_parameters
|
18
|
+
[name, *block.parameters.map(&:last).map(&:to_s).map(&:upcase)].join(" ").strip
|
19
|
+
end
|
20
|
+
|
17
21
|
def invoke(*args)
|
18
22
|
block.call(*args)
|
19
23
|
end
|
@@ -54,10 +58,10 @@ module Baptize
|
|
54
58
|
opts.separator ""
|
55
59
|
opts.separator "COMMANDS are ..."
|
56
60
|
|
57
|
-
width = [commands.values.map(&:
|
61
|
+
width = [commands.values.map(&:name_with_parameters).map(&:length), 31].flatten.max
|
58
62
|
commands.values.each do |command|
|
59
63
|
opts.separator sprintf(" %-#{width}s %s\n",
|
60
|
-
command.
|
64
|
+
command.name_with_parameters,
|
61
65
|
command.description)
|
62
66
|
end
|
63
67
|
|
data/lib/baptize/commands.rb
CHANGED
@@ -31,9 +31,16 @@ end
|
|
31
31
|
Baptize.application.define_command :deploy, "Deploys the configured policies to remote servers" do
|
32
32
|
registry = Baptize::Registry
|
33
33
|
registry.policies.keys.each do |role|
|
34
|
-
registry.
|
35
|
-
|
36
|
-
|
34
|
+
registry.apply_policy role
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# TODO: Maybe make this into options for deploy?
|
39
|
+
Baptize.application.define_command :force, "Force install a single package" do |package_name|
|
40
|
+
registry = Baptize::Registry
|
41
|
+
raise "No package '#{package_name}'" unless registry.has_package? package_name
|
42
|
+
registry.policies.keys.each do |role|
|
43
|
+
registry.apply_policy role, package: package_name, force: true
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
@@ -14,8 +14,8 @@ module Baptize
|
|
14
14
|
@after_block = nil
|
15
15
|
end
|
16
16
|
|
17
|
-
def execute
|
18
|
-
unless @registry.packages_executed.include?
|
17
|
+
def execute(options={})
|
18
|
+
unless @registry.packages_executed.include?(full_name) || options[:force]
|
19
19
|
@registry.packages_executed << full_name
|
20
20
|
logger.info "Resolving dependencies for #{name}"
|
21
21
|
@registry.before(self).each do |dependency|
|
data/lib/baptize/registry.rb
CHANGED
@@ -24,6 +24,10 @@ module Baptize
|
|
24
24
|
@packages ||= {}
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.has_package?(package_name)
|
28
|
+
!! @packages[package_name]
|
29
|
+
end
|
30
|
+
|
27
31
|
def self.packages_executed
|
28
32
|
@packages_executed ||= []
|
29
33
|
end
|
@@ -85,12 +89,14 @@ module Baptize
|
|
85
89
|
policies[role.to_sym] = package_names.map(&:to_s)
|
86
90
|
end
|
87
91
|
|
88
|
-
def self.apply_policy(role,
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
def self.apply_policy(role, options={})
|
93
|
+
ssh_for_role role do |host, ssh_for_role|
|
94
|
+
policies[role.to_sym].each do |package_name|
|
95
|
+
if options[:package].nil? || package_name.to_sym == options[:package].to_sym
|
96
|
+
raise "No package '#{package_name}'" unless packages[package_name]
|
97
|
+
packages[package_name].execute(force: options[:force])
|
98
|
+
end
|
99
|
+
end
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
@@ -122,6 +128,15 @@ module Baptize
|
|
122
128
|
SSHKit::Coordinator.new(Marshal.load(subset_copy)).each(options, &block)
|
123
129
|
end
|
124
130
|
|
131
|
+
def self.ssh_for_role(role, &block)
|
132
|
+
registry = self
|
133
|
+
for_role role, in: :parallel do |host|
|
134
|
+
registry.execution_scope.set :current_host, host
|
135
|
+
registry.execution_scope.set :current_ssh_connection, self
|
136
|
+
block.call
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
125
140
|
end # module Registry
|
126
141
|
|
127
142
|
end # module Baptize
|
data/lib/baptize/version.rb
CHANGED