chake 0.91 → 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 +4 -4
- data/.manifest +1 -0
- data/ChangeLog.md +10 -0
- data/README.md +15 -0
- data/Rakefile +1 -1
- data/lib/chake/config_manager/itamae.rb +6 -13
- data/lib/chake/config_manager/itamae_base.rb +23 -0
- data/lib/chake/config_manager/itamae_remote.rb +6 -13
- data/lib/chake/config_manager.rb +8 -4
- data/lib/chake/node.rb +9 -0
- data/lib/chake/version.rb +1 -1
- data/lib/chake.rb +17 -4
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e89bfb172b6733b9c8fb9b2d793e3b0470077850d294ec81c56a0bbc55a28b2
|
|
4
|
+
data.tar.gz: 59de754c4cb0ef93964711c9057db81da593aabaf95d83ff3ba7796719f3b979
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
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
|
```
|
|
@@ -254,6 +267,8 @@ converging. To do this, you just need to enhance the corresponding tasks:
|
|
|
254
267
|
* `connect_common`: executed before doing any action that connects to any of
|
|
255
268
|
the hosts. This can be used for example to generate a ssh configuration file
|
|
256
269
|
based on the contents of the nodes definition files.
|
|
270
|
+
* `connect:HOSTNAME`: executed before doing any action that connects to
|
|
271
|
+
`HOSTNAME`.
|
|
257
272
|
|
|
258
273
|
Example:
|
|
259
274
|
|
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'
|
|
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 <
|
|
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 <
|
|
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
|
data/lib/chake/config_manager.rb
CHANGED
|
@@ -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
|
-
|
|
52
|
-
|
|
55
|
+
Chake::ConfigManager.subclasses ||= []
|
|
56
|
+
Chake::ConfigManager.subclasses << klass
|
|
53
57
|
end
|
|
54
58
|
|
|
55
59
|
def self.get(node)
|
|
56
|
-
available =
|
|
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
|
-
|
|
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
data/lib/chake.rb
CHANGED
|
@@ -184,8 +184,15 @@ 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
|
-
task "apply:#{hostname}", [:recipe] =>
|
|
195
|
+
task "apply:#{hostname}", [:recipe] => [:recipe_input, :connect_common, "connect:#{hostname}"] do |_task, _args|
|
|
189
196
|
maybe_decrypt(node) do
|
|
190
197
|
node.apply($recipe_to_apply)
|
|
191
198
|
end
|
|
@@ -193,19 +200,22 @@ Chake.nodes.each do |node|
|
|
|
193
200
|
task "apply:#{hostname}" => converge_dependencies
|
|
194
201
|
|
|
195
202
|
desc "run a command on #{hostname}"
|
|
196
|
-
task "run:#{hostname}", [:command] =>
|
|
203
|
+
task "run:#{hostname}", [:command] => [:run_input, :connect_common, "connect:#{hostname}"] do
|
|
197
204
|
node.run($cmd_to_run)
|
|
198
205
|
end
|
|
199
206
|
|
|
200
207
|
desc "Logs in to a shell on #{hostname}"
|
|
201
|
-
task "login:#{hostname}" => :connect_common do
|
|
208
|
+
task "login:#{hostname}" => [:connect_common, "connect:#{hostname}"] do
|
|
202
209
|
node.run_shell
|
|
203
210
|
end
|
|
204
211
|
|
|
205
212
|
desc 'checks connectivity and setup on all nodes'
|
|
206
|
-
task "check:#{hostname}" => :connect_common do
|
|
213
|
+
task "check:#{hostname}" => [:connect_common, "connect:#{hostname}"] do
|
|
207
214
|
node.run('sudo echo OK')
|
|
208
215
|
end
|
|
216
|
+
|
|
217
|
+
# needs to be overridden in user projects
|
|
218
|
+
task "connect:#{hostname}"
|
|
209
219
|
end
|
|
210
220
|
|
|
211
221
|
task :run_input, :command do |_task, args|
|
|
@@ -259,6 +269,9 @@ multitask bootstrap: Chake.nodes.map { |node| "bootstrap:#{node.hostname}" }
|
|
|
259
269
|
desc 'converge all nodes (default)'
|
|
260
270
|
multitask 'converge' => Chake.nodes.map { |node| "converge:#{node.hostname}" }
|
|
261
271
|
|
|
272
|
+
desc 'Preview changes when converigng all nodes'
|
|
273
|
+
multitask 'preview' => Chake.nodes.map { |node| "preview:#{node.hostname}" }
|
|
274
|
+
|
|
262
275
|
desc 'Apply <recipe> on all nodes'
|
|
263
276
|
multitask 'apply', [:recipe] => Chake.nodes.map { |node| "apply:#{node.hostname}" }
|
|
264
277
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chake
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.93'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Antonio Terceiro
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -145,6 +144,7 @@ files:
|
|
|
145
144
|
- lib/chake/config_manager.rb
|
|
146
145
|
- lib/chake/config_manager/chef.rb
|
|
147
146
|
- lib/chake/config_manager/itamae.rb
|
|
147
|
+
- lib/chake/config_manager/itamae_base.rb
|
|
148
148
|
- lib/chake/config_manager/itamae_remote.rb
|
|
149
149
|
- lib/chake/config_manager/shell.rb
|
|
150
150
|
- lib/chake/config_manager/skel/chef/Rakefile
|
|
@@ -185,7 +185,6 @@ licenses:
|
|
|
185
185
|
- MIT
|
|
186
186
|
metadata:
|
|
187
187
|
rubygems_mfa_required: 'true'
|
|
188
|
-
post_install_message:
|
|
189
188
|
rdoc_options: []
|
|
190
189
|
require_paths:
|
|
191
190
|
- lib
|
|
@@ -200,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
200
199
|
- !ruby/object:Gem::Version
|
|
201
200
|
version: '0'
|
|
202
201
|
requirements: []
|
|
203
|
-
rubygems_version: 3.
|
|
204
|
-
signing_key:
|
|
202
|
+
rubygems_version: 3.6.7
|
|
205
203
|
specification_version: 4
|
|
206
204
|
summary: serverless configuration management tool for chef
|
|
207
205
|
test_files:
|