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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad98ebdbe3b5c570e1b16afd971758d7be6b8c94
4
- data.tar.gz: f10151aab4e40be681ebf14c6e66f4881f63fbd0
3
+ metadata.gz: b34dd42ccdba0c8f9a4d9cca33a451db3f8ba485
4
+ data.tar.gz: 701640fa69056abbda8784a261a3f3f74b30719b
5
5
  SHA512:
6
- metadata.gz: 2f737a1d1f690fafe84ccf3141ba1e4691b19416895079a1093f9b245c9135ee8c1148c69fbadd2388b7a48cec68d54dc84af7cbf32a23b41e418b2e04ca53f5
7
- data.tar.gz: 194aa44252afe3379155932a781dbb81440cecb3d426dec36a6365f86bc59211b7d5162b33b7cc22c737f283c85b1be43b8fa10284a8bf858b37cb79ccc4d280
6
+ metadata.gz: b1a5fb55be30db16631eb64afb79c0005776e9e7c5dd3e801ea4f684d359e3b0eeca671f9dedbc32cbff250dcc1e39c6a79266283ff7c600e7808fdee408d55a
7
+ data.tar.gz: 1f00a6870ea94bc510c0fc499a851126737ad4d99150d12b30d13336b22fe7cf16d87bdaddc28043629252a329862a4e465e8c5cc404d85eda6fcb3b7740cf0b
@@ -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(&:name).map(&:length), 31].flatten.max
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.name,
64
+ command.name_with_parameters,
61
65
  command.description)
62
66
  end
63
67
 
@@ -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.for_role role, in: :parallel do |host|
35
- registry.apply_policy role, host, self
36
- end
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? full_name
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|
@@ -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, host, ssh_connection)
89
- execution_scope.set :current_host, host
90
- execution_scope.set :current_ssh_connection, ssh_connection
91
- policies[role.to_sym].each do |package_name|
92
- raise "No package '#{package_name}'" unless packages[package_name]
93
- packages[package_name].execute
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
@@ -1,3 +1,3 @@
1
1
  module Baptize
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end # module Baptize
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baptize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Troels Knak-Nielsen