chake 0.92 → 0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 796da031fd0926e8f4a2ba13a949dc6b308d0ceb811a8568db08a5ca54f99a07
4
- data.tar.gz: ab0c285bbbe3a7e8ce6b665ac63de976c4a6239ebc2e356ec7f8ded4caaa0f3a
3
+ metadata.gz: 8e89bfb172b6733b9c8fb9b2d793e3b0470077850d294ec81c56a0bbc55a28b2
4
+ data.tar.gz: 59de754c4cb0ef93964711c9057db81da593aabaf95d83ff3ba7796719f3b979
5
5
  SHA512:
6
- metadata.gz: 2f8ee4d755b3beb84e101c694823e685ce121ec4b26183b0048db91da7d5ced6fcda624fc29cd96f6e111aa28d6e4a4b13e145d7f5887bf59032b3c1db868691
7
- data.tar.gz: 0320fe56feaf9a4c8e514cbf33cfff46cd24f68daa88ab6c74e88ab475d8e4c13b0ac7477a463a28478aa38cad55dd588cfbe028ff1315fd62c1baf71d8e5bbb
6
+ metadata.gz: fb264a8d9d1781b336c16c84f96bec3ee6cbf858c68804660b98eae5fa747dcb8b155166dd8c91e7c8baf68f77f5a2f8cde59406495c538d7502955cf1b87968
7
+ data.tar.gz: 6f12e02d6186521dcb72405f407cc3b5d4e27e7570b31a7b86fdd445c949c9322ce7004c6582cd375bbeaab2c3c07e9631f3d2e99c4a288fb68b14f697a01c55
data/.manifest CHANGED
@@ -37,6 +37,7 @@ lib/chake/config.rb
37
37
  lib/chake/config_manager.rb
38
38
  lib/chake/config_manager/chef.rb
39
39
  lib/chake/config_manager/itamae.rb
40
+ lib/chake/config_manager/itamae_base.rb
40
41
  lib/chake/config_manager/itamae_remote.rb
41
42
  lib/chake/config_manager/shell.rb
42
43
  lib/chake/config_manager/skel/chef/Rakefile
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.93
2
+
3
+ - Chef::ConfigManager: add support for inheritance
4
+ - itamae: extract common code into subclass
5
+ - Add support for a preview action
6
+
1
7
  # 0.92
2
8
 
3
9
  - Add support for connect:$HOST hooks
data/README.md CHANGED
@@ -153,6 +153,19 @@ To apply the configuration to a single node, run
153
153
  $ rake converge:$NODE
154
154
  ```
155
155
 
156
+ To preview the changes that would have been made when `converge` is run, you
157
+ can issue the `preview` command:
158
+
159
+ ```
160
+ $ rake preview
161
+ ```
162
+
163
+ To preview the changes that would have been done to a single node, run:
164
+
165
+ ```
166
+ $ rake preview:$NODE
167
+ ```
168
+
156
169
  To apply a single recipe on all nodes, run
157
170
 
158
171
  ```
data/Rakefile CHANGED
@@ -100,7 +100,7 @@ end
100
100
 
101
101
  desc 'Check spelling in the source code'
102
102
  task :codespell do
103
- sh 'codespell', '--skip=.git', '--skip=coverage', '--skip=*.asc', '--skip=*.swp', '--skip=tags', '--skip=*.1'
103
+ sh 'codespell', '--skip=.git', '--skip=coverage', '--skip=*.asc', '--skip=*.swp', '--skip=tags', '--skip=*.1', '--skip=pkg'
104
104
  end
105
105
 
106
106
  task default: [:test, :style, :codespell]
@@ -1,21 +1,11 @@
1
1
  require 'shellwords'
2
2
  require 'chake/config'
3
3
  require 'chake/tmpdir'
4
+ require 'chake/config_manager/itamae_base'
4
5
 
5
6
  module Chake
6
7
  class ConfigManager
7
- class Itamae < ConfigManager
8
- def converge
9
- recipes = node.data['itamae']
10
- return if recipes.empty?
11
-
12
- run_itamae(*recipes)
13
- end
14
-
15
- def apply(config)
16
- run_itamae(config)
17
- end
18
-
8
+ class Itamae < ItamaeBase
19
9
  def needs_upload?
20
10
  false
21
11
  end
@@ -26,7 +16,7 @@ module Chake
26
16
 
27
17
  private
28
18
 
29
- def run_itamae(*recipes)
19
+ def run_itamae(preview, *recipes)
30
20
  cmd = ['itamae']
31
21
  case node.connection
32
22
  when Chake::Connection::Ssh
@@ -44,6 +34,9 @@ module Chake
44
34
  if node.silent
45
35
  cmd << '--log-level=warn'
46
36
  end
37
+ if preview
38
+ cmd << '--dry-run'
39
+ end
47
40
  cmd += recipes
48
41
  node.log("$ #{cmd.join(' ')}")
49
42
  io = IO.popen(cmd, 'r', err: %i[child out])
@@ -0,0 +1,23 @@
1
+ module Chake
2
+ class ConfigManager
3
+ class ItamaeBase < ConfigManager
4
+ def converge
5
+ recipes = node.data[name]
6
+ return if recipes.empty?
7
+
8
+ run_itamae(false, *recipes)
9
+ end
10
+
11
+ def preview
12
+ recipes = node.data['itamae-remote']
13
+ return if recipes.empty?
14
+
15
+ run_itamae(true, *recipes)
16
+ end
17
+
18
+ def apply(config)
19
+ run_itamae(false, config)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,21 +1,11 @@
1
1
  require 'shellwords'
2
2
  require 'chake/config'
3
3
  require 'chake/tmpdir'
4
+ require 'chake/config_manager/itamae_base'
4
5
 
5
6
  module Chake
6
7
  class ConfigManager
7
- class ItamaeRemote < ConfigManager
8
- def converge
9
- recipes = node.data['itamae-remote']
10
- return if recipes.empty?
11
-
12
- run_itamae(*recipes)
13
- end
14
-
15
- def apply(config)
16
- run_itamae(config)
17
- end
18
-
8
+ class ItamaeRemote < ItamaeBase
19
9
  def needs_upload?
20
10
  true
21
11
  end
@@ -26,11 +16,14 @@ module Chake
26
16
 
27
17
  private
28
18
 
29
- def run_itamae(*recipes)
19
+ def run_itamae(preview, *recipes)
30
20
  cmd = ['itamae', 'local', "--node-json=#{json_config}"]
31
21
  if node.silent
32
22
  cmd << '--log-level=warn'
33
23
  end
24
+ if preview
25
+ cmd << '--dry-run'
26
+ end
34
27
  cmd += recipes.map { |r| File.join(node.path, r) }
35
28
  node.run_as_root(Shellwords.join(cmd))
36
29
  end
@@ -46,14 +46,18 @@ module Chake
46
46
  @priority ||= new_priority || 50
47
47
  end
48
48
 
49
+ class << self
50
+ attr_accessor :subclasses
51
+ end
52
+
49
53
  def self.inherited(klass)
50
54
  super
51
- @subclasses ||= []
52
- @subclasses << klass
55
+ Chake::ConfigManager.subclasses ||= []
56
+ Chake::ConfigManager.subclasses << klass
53
57
  end
54
58
 
55
59
  def self.get(node)
56
- available = @subclasses.sort_by(&:priority)
60
+ available = subclasses.sort_by(&:priority)
57
61
  manager = available.find { |c| c.short_name == node.data['config_manager'] }
58
62
  manager ||= available.find { |c| c.accept?(node) }
59
63
  raise ArgumentError, "Can't find configuration manager class for node #{node.hostname}. Available: #{available}.join(', ')}" unless manager
@@ -66,7 +70,7 @@ module Chake
66
70
  end
67
71
 
68
72
  def self.all
69
- @subclasses
73
+ subclasses
70
74
  end
71
75
 
72
76
  def self.init
data/lib/chake/node.rb CHANGED
@@ -45,6 +45,15 @@ module Chake
45
45
 
46
46
  def_delegators :config_manager, :converge, :apply, :path, :bootstrap_steps, :needs_upload?
47
47
 
48
+ def preview
49
+ unless config_manager.respond_to?(:preview)
50
+ puts "I: the #{config_manager} driver does not support preview"
51
+ return
52
+ end
53
+
54
+ config_manager.preview
55
+ end
56
+
48
57
  def path
49
58
  @path ||= config_manager.path
50
59
  end
data/lib/chake/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chake
2
- VERSION = '0.92'.freeze
2
+ VERSION = '0.93'.freeze
3
3
  end
data/lib/chake.rb CHANGED
@@ -184,6 +184,13 @@ Chake.nodes.each do |node|
184
184
  end
185
185
  end
186
186
 
187
+ desc "Preview changes when converging #{hostname}"
188
+ task "preview:#{hostname}" => converge_dependencies do
189
+ maybe_decrypt(node) do
190
+ node.dry_run
191
+ end
192
+ end
193
+
187
194
  desc 'apply <recipe> on #{hostname}'
188
195
  task "apply:#{hostname}", [:recipe] => [:recipe_input, :connect_common, "connect:#{hostname}"] do |_task, _args|
189
196
  maybe_decrypt(node) do
@@ -262,6 +269,9 @@ multitask bootstrap: Chake.nodes.map { |node| "bootstrap:#{node.hostname}" }
262
269
  desc 'converge all nodes (default)'
263
270
  multitask 'converge' => Chake.nodes.map { |node| "converge:#{node.hostname}" }
264
271
 
272
+ desc 'Preview changes when converigng all nodes'
273
+ multitask 'preview' => Chake.nodes.map { |node| "preview:#{node.hostname}" }
274
+
265
275
  desc 'Apply <recipe> on all nodes'
266
276
  multitask 'apply', [:recipe] => Chake.nodes.map { |node| "apply:#{node.hostname}" }
267
277
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chake
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.92'
4
+ version: '0.93'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Terceiro
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -144,6 +144,7 @@ files:
144
144
  - lib/chake/config_manager.rb
145
145
  - lib/chake/config_manager/chef.rb
146
146
  - lib/chake/config_manager/itamae.rb
147
+ - lib/chake/config_manager/itamae_base.rb
147
148
  - lib/chake/config_manager/itamae_remote.rb
148
149
  - lib/chake/config_manager/shell.rb
149
150
  - lib/chake/config_manager/skel/chef/Rakefile
@@ -198,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  - !ruby/object:Gem::Version
199
200
  version: '0'
200
201
  requirements: []
201
- rubygems_version: 3.6.3
202
+ rubygems_version: 3.6.7
202
203
  specification_version: 4
203
204
  summary: serverless configuration management tool for chef
204
205
  test_files: