chake 0.19 → 0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +8 -0
  3. data/README.md +14 -0
  4. data/Rakefile +7 -4
  5. data/bin/chake +11 -0
  6. data/chake.gemspec +1 -1
  7. data/coverage/assets/0.10.0/application.css +799 -0
  8. data/coverage/assets/0.10.0/application.js +34783 -0
  9. data/coverage/assets/0.10.0/colorbox/border.png +0 -0
  10. data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  11. data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  12. data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  13. data/coverage/assets/0.10.0/favicon_green.png +0 -0
  14. data/coverage/assets/0.10.0/favicon_red.png +0 -0
  15. data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  16. data/coverage/assets/0.10.0/loading.gif +0 -0
  17. data/coverage/assets/0.10.0/magnify.png +0 -0
  18. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  19. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  20. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  21. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  22. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  23. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  24. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  25. data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  26. data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  27. data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  28. data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  29. data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  30. data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  31. data/coverage/index.html +2326 -0
  32. data/lib/chake.rb +17 -26
  33. data/lib/chake/backend.rb +5 -3
  34. data/lib/chake/config.rb +21 -0
  35. data/lib/chake/version.rb +1 -1
  36. data/spec/spec_helper.rb +3 -1
  37. metadata +28 -5
  38. data/.gitignore +0 -20
  39. data/.gitlab-ci.yml +0 -12
  40. data/man/.gitignore +0 -2
@@ -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
- $nodes.each do |node|
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($chake_tmpdir, node + '.' + group_name + '.sha1sum')
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
- $nodes.each do |node|
138
+ Chake.nodes.each do |node|
148
139
 
149
140
  hostname = node.hostname
150
- bootstrap_script = File.join($chake_tmpdir, 'bootstrap-' + hostname)
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($chake_tmpdir, hostname + '.json')
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($chake_tmpdir, '*.sha1sum'))
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}/#{$chake_tmpdir}/#{hostname}.json"
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}/#{$chake_tmpdir}/#{hostname}.json --override-runlist recipe[#{$recipe_to_apply}]"
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 true')
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 => $nodes.map { |node| "upload:#{node.hostname}" }
289
+ multitask :upload => Chake.nodes.map { |node| "upload:#{node.hostname}" }
299
290
 
300
291
  desc "bootstrap all nodes"
301
- multitask :bootstrap => $nodes.map { |node| "bootstrap:#{node.hostname}" }
292
+ multitask :bootstrap => Chake.nodes.map { |node| "bootstrap:#{node.hostname}" }
302
293
 
303
294
  desc "converge all nodes (default)"
304
- multitask "converge" => $nodes.map { |node| "converge:#{node.hostname}" }
295
+ multitask "converge" => Chake.nodes.map { |node| "converge:#{node.hostname}" }
305
296
 
306
297
  desc "Apply <recipe> on all nodes"
307
- multitask "apply", [:recipe] => $nodes.map { |node| "apply:#{node.hostname}" }
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] => $nodes.map { |node| "run:#{node.hostname}" }
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 => ($nodes.map { |node| "check:#{node.hostname}" }) do
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 $nodes'
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
@@ -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
- output = IO.popen(command_runner + [cmd], err: [:child, :out])
27
- output.each_line do |line|
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
- output.close
32
+ io.close
31
33
  if $?
32
34
  status = $?.exitstatus
33
35
  if status != 0
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Chake
2
- VERSION = "0.19"
2
+ VERSION = "0.20"
3
3
  end
@@ -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 + ['something'], Hash).and_return(io)
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.19'
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-08-17 00:00:00.000000000 Z
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
@@ -1,12 +0,0 @@
1
- before_script:
2
- - pwd
3
- - echo $USER
4
- - bundle install --path .bundle
5
-
6
- tests:
7
- script:
8
- - bundle exec rake
9
- - bundle exec rake -f man/Rakefile
10
- cache:
11
- paths:
12
- - .bundle
@@ -1,2 +0,0 @@
1
- chake.1*
2
- chake.adoc