chake 0.19 → 0.20
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/ChangeLog.md +8 -0
- data/README.md +14 -0
- data/Rakefile +7 -4
- data/bin/chake +11 -0
- data/chake.gemspec +1 -1
- data/coverage/assets/0.10.0/application.css +799 -0
- data/coverage/assets/0.10.0/application.js +34783 -0
- data/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.0/loading.gif +0 -0
- data/coverage/assets/0.10.0/magnify.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +2326 -0
- data/lib/chake.rb +17 -26
- data/lib/chake/backend.rb +5 -3
- data/lib/chake/config.rb +21 -0
- data/lib/chake/version.rb +1 -1
- data/spec/spec_helper.rb +3 -1
- metadata +28 -5
- data/.gitignore +0 -20
- data/.gitlab-ci.yml +0 -12
- data/man/.gitignore +0 -2
data/lib/chake.rb
CHANGED
@@ -4,20 +4,11 @@ require 'yaml'
|
|
4
4
|
require 'json'
|
5
5
|
require 'tmpdir'
|
6
6
|
|
7
|
+
require 'chake/config'
|
7
8
|
require 'chake/version'
|
8
|
-
require 'chake/node'
|
9
9
|
require 'chake/readline'
|
10
10
|
require 'chake/tmpdir'
|
11
11
|
|
12
|
-
chef_config = ENV['CHAKE_CHEF_CONFIG'] || 'config.rb'
|
13
|
-
nodes_file = ENV['CHAKE_NODES'] || 'nodes.yaml'
|
14
|
-
nodes_directory = ENV['CHAKE_NODES_D'] || 'nodes.d'
|
15
|
-
node_data = File.exists?(nodes_file) && YAML.load_file(nodes_file) || {}
|
16
|
-
Dir.glob(File.join(nodes_directory, '*.yaml')).sort.each do |f|
|
17
|
-
node_data.merge!(YAML.load_file(f))
|
18
|
-
end
|
19
|
-
$nodes = node_data.map { |node,data| Chake::Node.new(node, data) }.reject(&:skip?).uniq(&:hostname)
|
20
|
-
$chake_tmpdir = Chake.tmpdir
|
21
12
|
|
22
13
|
desc "Initializes current directory with sample structure"
|
23
14
|
task :init do
|
@@ -84,7 +75,7 @@ end
|
|
84
75
|
|
85
76
|
desc 'list nodes'
|
86
77
|
task :nodes do
|
87
|
-
|
78
|
+
Chake.nodes.each do |node|
|
88
79
|
puts "%-40s %-5s\n" % [node.hostname, node.backend]
|
89
80
|
end
|
90
81
|
end
|
@@ -106,7 +97,7 @@ def if_files_changed(node, group_name, files)
|
|
106
97
|
hash_io.close_write
|
107
98
|
current_hash = hash_io.read
|
108
99
|
|
109
|
-
hash_file = File.join(
|
100
|
+
hash_file = File.join(Chake.tmpdir, node + '.' + group_name + '.sha1sum')
|
110
101
|
hash_on_disk = nil
|
111
102
|
if File.exists?(hash_file)
|
112
103
|
hash_on_disk = File.read(hash_file)
|
@@ -144,10 +135,10 @@ task :converge_common => :connect_common
|
|
144
135
|
desc 'Executed before connecting to any host'
|
145
136
|
task :connect_common
|
146
137
|
|
147
|
-
|
138
|
+
Chake.nodes.each do |node|
|
148
139
|
|
149
140
|
hostname = node.hostname
|
150
|
-
bootstrap_script = File.join(
|
141
|
+
bootstrap_script = File.join(Chake.tmpdir, 'bootstrap-' + hostname)
|
151
142
|
|
152
143
|
file bootstrap_script => bootstrap_steps do |t|
|
153
144
|
mkdir_p(File.dirname(bootstrap_script))
|
@@ -163,7 +154,7 @@ $nodes.each do |node|
|
|
163
154
|
|
164
155
|
desc "bootstrap #{hostname}"
|
165
156
|
task "bootstrap:#{hostname}" => [:bootstrap_common, bootstrap_script] do
|
166
|
-
config = File.join(
|
157
|
+
config = File.join(Chake.tmpdir, hostname + '.json')
|
167
158
|
|
168
159
|
if File.exists?(config)
|
169
160
|
# already bootstrapped, just overwrite
|
@@ -196,7 +187,7 @@ $nodes.each do |node|
|
|
196
187
|
rsync = node.rsync + ["-avp"] + ENV.fetch('CHAKE_RSYNC_OPTIONS', '').split
|
197
188
|
rsync_logging = Rake.application.options.silent && '--quiet' || '--verbose'
|
198
189
|
|
199
|
-
hash_files = Dir.glob(File.join(
|
190
|
+
hash_files = Dir.glob(File.join(Chake.tmpdir, '*.sha1sum'))
|
200
191
|
files = Dir.glob("**/*").select { |f| !File.directory?(f) } - encrypted.keys - encrypted.values - hash_files
|
201
192
|
if_files_changed(hostname, 'plain', files) do
|
202
193
|
sh *rsync, '--delete', rsync_logging, *rsync_excludes, './', node.rsync_dest
|
@@ -225,13 +216,13 @@ $nodes.each do |node|
|
|
225
216
|
desc "converge #{hostname}"
|
226
217
|
task "converge:#{hostname}" => converge_dependencies do
|
227
218
|
chef_logging = Rake.application.options.silent && '-l fatal' || ''
|
228
|
-
node.run_as_root "chef-solo -c #{node.path}/#{chef_config} #{chef_logging} -j #{node.path}/#{
|
219
|
+
node.run_as_root "chef-solo -c #{node.path}/#{Chake.chef_config} #{chef_logging} -j #{node.path}/#{Chake.tmpdir}/#{hostname}.json"
|
229
220
|
end
|
230
221
|
|
231
222
|
desc 'apply <recipe> on #{hostname}'
|
232
223
|
task "apply:#{hostname}", [:recipe] => [:recipe_input, :connect_common] do |task, args|
|
233
224
|
chef_logging = Rake.application.options.silent && '-l fatal' || ''
|
234
|
-
node.run_as_root "chef-solo -c #{node.path}/#{chef_config} #{chef_logging} -j #{node.path}/#{
|
225
|
+
node.run_as_root "chef-solo -c #{node.path}/#{Chake.chef_config} #{chef_logging} -j #{node.path}/#{Chake.tmpdir}/#{hostname}.json --override-runlist recipe[#{$recipe_to_apply}]"
|
235
226
|
end
|
236
227
|
task "apply:#{hostname}" => converge_dependencies
|
237
228
|
|
@@ -247,7 +238,7 @@ $nodes.each do |node|
|
|
247
238
|
|
248
239
|
desc 'checks connectivity and setup on all nodes'
|
249
240
|
task "check:#{hostname}" => :connect_common do
|
250
|
-
node.run('sudo
|
241
|
+
node.run('sudo echo OK')
|
251
242
|
end
|
252
243
|
|
253
244
|
end
|
@@ -295,24 +286,24 @@ task :recipe_input, :recipe do |task,args|
|
|
295
286
|
end
|
296
287
|
|
297
288
|
desc "upload to all nodes"
|
298
|
-
multitask :upload =>
|
289
|
+
multitask :upload => Chake.nodes.map { |node| "upload:#{node.hostname}" }
|
299
290
|
|
300
291
|
desc "bootstrap all nodes"
|
301
|
-
multitask :bootstrap =>
|
292
|
+
multitask :bootstrap => Chake.nodes.map { |node| "bootstrap:#{node.hostname}" }
|
302
293
|
|
303
294
|
desc "converge all nodes (default)"
|
304
|
-
multitask "converge" =>
|
295
|
+
multitask "converge" => Chake.nodes.map { |node| "converge:#{node.hostname}" }
|
305
296
|
|
306
297
|
desc "Apply <recipe> on all nodes"
|
307
|
-
multitask "apply", [:recipe] =>
|
298
|
+
multitask "apply", [:recipe] => Chake.nodes.map { |node| "apply:#{node.hostname}" }
|
308
299
|
|
309
300
|
desc "run <command> on all nodes"
|
310
|
-
multitask :run, [:command] =>
|
301
|
+
multitask :run, [:command] => Chake.nodes.map { |node| "run:#{node.hostname}" }
|
311
302
|
|
312
303
|
task :default => :converge
|
313
304
|
|
314
305
|
desc 'checks connectivity and setup on all nodes'
|
315
|
-
multitask :check => (
|
306
|
+
multitask :check => (Chake.nodes.map { |node| "check:#{node.hostname}" }) do
|
316
307
|
puts "✓ all hosts OK"
|
317
308
|
puts " - ssh connection works"
|
318
309
|
puts " - password-less sudo works"
|
@@ -326,7 +317,7 @@ task :console do
|
|
326
317
|
|
327
318
|
puts 'chake - interactive console'
|
328
319
|
puts '---------------------------'
|
329
|
-
puts 'all node data in available in
|
320
|
+
puts 'all node data in available in Chake.nodes'
|
330
321
|
puts
|
331
322
|
IRB::Irb.new(workspace).run(IRB.conf)
|
332
323
|
end
|
data/lib/chake/backend.rb
CHANGED
@@ -23,11 +23,13 @@ module Chake
|
|
23
23
|
|
24
24
|
def run(cmd)
|
25
25
|
printf "%#{Node.max_node_name_length}s: $ %s\n", node.hostname, cmd
|
26
|
-
|
27
|
-
|
26
|
+
io = IO.popen(command_runner + ['/bin/sh'], mode='w+', eer: [:child, :out])
|
27
|
+
io.write(cmd)
|
28
|
+
io.close_write
|
29
|
+
io.each_line do |line|
|
28
30
|
printf "%#{Node.max_node_name_length}s: %s\n", node.hostname, line.strip
|
29
31
|
end
|
30
|
-
|
32
|
+
io.close
|
31
33
|
if $?
|
32
34
|
status = $?.exitstatus
|
33
35
|
if status != 0
|
data/lib/chake/config.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'chake/node'
|
2
|
+
|
3
|
+
module Chake
|
4
|
+
class << self
|
5
|
+
attr_accessor :chef_config
|
6
|
+
attr_accessor :nodes
|
7
|
+
attr_accessor :tmpdir
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
chef_config = ENV['CHAKE_CHEF_CONFIG'] || 'config.rb'
|
12
|
+
nodes_file = ENV['CHAKE_NODES'] || 'nodes.yaml'
|
13
|
+
nodes_directory = ENV['CHAKE_NODES_D'] || 'nodes.d'
|
14
|
+
node_data = File.exists?(nodes_file) && YAML.load_file(nodes_file) || {}
|
15
|
+
Dir.glob(File.join(nodes_directory, '*.yaml')).sort.each do |f|
|
16
|
+
node_data.merge!(YAML.load_file(f))
|
17
|
+
end
|
18
|
+
|
19
|
+
Chake.chef_config = chef_config
|
20
|
+
Chake.nodes = node_data.map { |node,data| Chake::Node.new(node, data) }.reject(&:skip?).uniq(&:hostname)
|
21
|
+
Chake.tmpdir = Chake.tmpdir
|
data/lib/chake/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -20,7 +20,9 @@ shared_examples "Chake::Backend" do |backend_class|
|
|
20
20
|
|
21
21
|
it('runs commands') do
|
22
22
|
io = StringIO.new("line 1\nline 2\n")
|
23
|
-
expect(IO).to receive(:popen).with(backend.command_runner + ['
|
23
|
+
expect(IO).to receive(:popen).with(backend.command_runner + ['/bin/sh'], mode='w+', Hash).and_return(io)
|
24
|
+
expect(io).to receive(:write).with('something').ordered
|
25
|
+
expect(io).to receive(:close_write).ordered
|
24
26
|
expect(backend).to receive(:printf).with(anything, "myhost", "something")
|
25
27
|
expect(backend).to receive(:printf).with(anything, "myhost", "line 1")
|
26
28
|
expect(backend).to receive(:printf).with(anything, "myhost", "line 2")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.20'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonio Terceiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,8 +92,6 @@ executables:
|
|
92
92
|
extensions: []
|
93
93
|
extra_rdoc_files: []
|
94
94
|
files:
|
95
|
-
- ".gitignore"
|
96
|
-
- ".gitlab-ci.yml"
|
97
95
|
- ChangeLog.md
|
98
96
|
- Gemfile
|
99
97
|
- LICENSE.txt
|
@@ -102,6 +100,31 @@ files:
|
|
102
100
|
- bin/chake
|
103
101
|
- chake.gemspec
|
104
102
|
- chake.spec.erb
|
103
|
+
- coverage/assets/0.10.0/application.css
|
104
|
+
- coverage/assets/0.10.0/application.js
|
105
|
+
- coverage/assets/0.10.0/colorbox/border.png
|
106
|
+
- coverage/assets/0.10.0/colorbox/controls.png
|
107
|
+
- coverage/assets/0.10.0/colorbox/loading.gif
|
108
|
+
- coverage/assets/0.10.0/colorbox/loading_background.png
|
109
|
+
- coverage/assets/0.10.0/favicon_green.png
|
110
|
+
- coverage/assets/0.10.0/favicon_red.png
|
111
|
+
- coverage/assets/0.10.0/favicon_yellow.png
|
112
|
+
- coverage/assets/0.10.0/loading.gif
|
113
|
+
- coverage/assets/0.10.0/magnify.png
|
114
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
|
115
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
|
116
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
|
117
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
|
118
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png
|
119
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
|
120
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
|
121
|
+
- coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
|
122
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png
|
123
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png
|
124
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png
|
125
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png
|
126
|
+
- coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png
|
127
|
+
- coverage/index.html
|
105
128
|
- examples/test/Rakefile
|
106
129
|
- examples/test/config.rb
|
107
130
|
- examples/test/cookbooks/example/files/host-homer/test.asc
|
@@ -113,11 +136,11 @@ files:
|
|
113
136
|
- lib/chake/bootstrap/00_set_hostname.sh
|
114
137
|
- lib/chake/bootstrap/01_debian.sh
|
115
138
|
- lib/chake/bootstrap/99_unsupported.sh
|
139
|
+
- lib/chake/config.rb
|
116
140
|
- lib/chake/node.rb
|
117
141
|
- lib/chake/readline.rb
|
118
142
|
- lib/chake/tmpdir.rb
|
119
143
|
- lib/chake/version.rb
|
120
|
-
- man/.gitignore
|
121
144
|
- man/Rakefile
|
122
145
|
- man/readme2man.sed
|
123
146
|
- spec/chake/backend/local_spec.rb
|
data/.gitignore
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
/examples/test/nodes.yaml
|
19
|
-
/examples/test/.tmp
|
20
|
-
.*.html
|
data/.gitlab-ci.yml
DELETED
data/man/.gitignore
DELETED