chake 0.80 → 0.81

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
  SHA256:
3
- metadata.gz: e0276e69503885ac871f9c3b73025598fe4401dd361e78e90d5921a873395a9b
4
- data.tar.gz: 5e132b6715fb2f087ecfd72a411c8ab371f1bb0da63f7bf74def69e1c028fd15
3
+ metadata.gz: 8b68eda0401a07074704cfd0627f29423cd659a29a048e30afb60eb14c78c7e0
4
+ data.tar.gz: 031031b2e5bb12c185c974960aa1dd0dd538c31323510f1cb90843c9f7981dca
5
5
  SHA512:
6
- metadata.gz: '0914e13f840deaaba8a80eb7052006659e023ba8ea0c53aad08416cd56bedd2b66807f939352a7e57f53dad28cdcba5241884db461252dd909b4b09902d5d45f'
7
- data.tar.gz: a0de67988cecfde1355cf0ebe21b778cb0fa51db7c6d572965ab34a2bb6eed43c88db7a8ef4eddf4f595344fc5685a2f11e67691ec82e90a81de314b15e39e90
6
+ metadata.gz: 51c7b6ad543209fb895f25b7f436f882731e1bc60880dd66e37a7240ec03bd3608bb99b4fcc8611caf3d9203394389e76f9c6608d8d98242b5119e0ccc87b20f
7
+ data.tar.gz: 7270ec17c14d6adc02230b57042a1f4585b706761facef2f8118cb1980cd61c8ea87d4899b52232bfa6a8574f31db3bd69287b7178803cd42783164f61f3e3bf
data/.ackrc CHANGED
@@ -1 +1,2 @@
1
1
  --ignore-dir=coverage
2
+ --ignore-dir=pkg
@@ -1,7 +1,7 @@
1
1
  image: debian:testing
2
2
 
3
3
  .install: &install
4
- - apt-get update && apt-get install -qy ruby asciidoctor ruby-bundler ruby-rspec rubocop ruby-simplecov codespell
4
+ - apt-get update && apt-get install -qy ruby asciidoctor ruby-bundler ruby-rspec rubocop ruby-simplecov codespell ronn
5
5
 
6
6
  tests:
7
7
  before_script: *install
data/.manifest CHANGED
@@ -25,7 +25,8 @@ examples/test/cookbooks/example/files/host-lemur/test.asc
25
25
  examples/test/cookbooks/example/recipes/default.rb
26
26
  lib/chake.rb
27
27
  lib/chake/bootstrap/00_set_hostname.sh
28
- lib/chake/bootstrap/chef/01_debian.sh
28
+ lib/chake/bootstrap/chef/01_installed.sh
29
+ lib/chake/bootstrap/chef/02_debian.sh
29
30
  lib/chake/bootstrap/chef/99_unsupported.sh
30
31
  lib/chake/config.rb
31
32
  lib/chake/config_manager.rb
@@ -49,6 +50,7 @@ lib/chake/node.rb
49
50
  lib/chake/readline.rb
50
51
  lib/chake/tmpdir.rb
51
52
  lib/chake/version.rb
53
+ lib/chake/wipe.rb
52
54
  man/.gitignore
53
55
  man/Rakefile
54
56
  man/readme2man.sed
@@ -2,6 +2,8 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
4
  NewCops: enable
5
+ Exclude:
6
+ - pkg/**/*
5
7
 
6
8
  Layout/LineLength:
7
9
  Enabled: false
@@ -1,3 +1,11 @@
1
+ # 0.81
2
+
3
+ * bootstrap/chef: exit if chef-solo is available
4
+ * Always bootstrap nodes
5
+ * Decrypt files in place when upload is not needed
6
+ * itamae: handle silent mode
7
+ * manpages: drop accute accent erroneously added by ronn
8
+
1
9
  # 0.80
2
10
 
3
11
  This release adds support for multiple configuration managers. Chef is now only
data/README.md CHANGED
@@ -11,8 +11,8 @@ chake(1) -- serverless configuration management tool
11
11
 
12
12
  chake is a tool that helps you manage multiple hosts without the need for a
13
13
  central server. Configuration is managed in a local directory, which should
14
- (but doesn't need to ) be under version control with **git(1)** or any other
15
- version control system. áéíóú
14
+ (but doesn't need to) be under version control with **git(1)** or any other
15
+ version control system.
16
16
 
17
17
  Configuration is deployed to managed hosts remotely, either by invoking a
18
18
  configuration management tool that will connect to them, or by first uploading
@@ -271,6 +271,14 @@ required files to be sent). You can use them to store passwords and other
271
271
  sensitive information (SSL keys, etc) in the repository together with the rest
272
272
  of the configuration.
273
273
 
274
+ For configuration managers that don't require uploading files to the managed
275
+ node, this decryption will happen right before converging or applying single
276
+ recipes, and the decrypted files will be wiped right after that.
277
+
278
+ If you use this feature, make sure that you have the `wipe` program installed.
279
+ This way chake will be able to delete the decrypted files in a slightly more
280
+ secure way, after being done with them.
281
+
274
282
  ### repository-local SSH configuration
275
283
 
276
284
  If you need special SSH configuration parameters, you can create a file called
data/Rakefile CHANGED
@@ -107,4 +107,6 @@ end
107
107
 
108
108
  task default: [:test, :style, :codespell]
109
109
 
110
+ task clean: 'bundler:clobber'
111
+
110
112
  load './man/Rakefile'
@@ -5,6 +5,7 @@ require 'tmpdir'
5
5
  require 'chake/config'
6
6
  require 'chake/version'
7
7
  require 'chake/readline'
8
+ require 'chake/wipe'
8
9
 
9
10
  desc 'Initializes current directory with sample structure'
10
11
  task init: 'init:itamae'
@@ -34,6 +35,24 @@ def encrypted_for(node)
34
35
  end
35
36
  end
36
37
 
38
+ def maybe_decrypt(node)
39
+ if node.needs_upload?
40
+ return yield
41
+ end
42
+
43
+ files = encrypted_for(node.hostname)
44
+ files.each do |encrypted, target|
45
+ sh "gpg --use-agent --quiet --decrypt --output #{target} #{encrypted}"
46
+ end
47
+ begin
48
+ yield
49
+ ensure
50
+ files.each do |_, target|
51
+ Chake::Wipe.instance.wipe(target)
52
+ end
53
+ end
54
+ end
55
+
37
56
  def if_files_changed(node, group_name, files)
38
57
  return if files.empty?
39
58
 
@@ -87,7 +106,7 @@ Chake.nodes.each do |node|
87
106
  desc "bootstrap #{hostname}"
88
107
  task "bootstrap:#{hostname}" => :bootstrap_common do
89
108
  mkdir_p Chake.tmpdir unless File.directory?(Chake.tmpdir)
90
- if node.needs_bootstrap? && (!File.exist?(bootstrap_script) || File.read(bootstrap_script) != bootstrap_code)
109
+ if !File.exist?(bootstrap_script) || File.read(bootstrap_script) != bootstrap_code
91
110
 
92
111
  # create bootstrap script
93
112
  File.open(bootstrap_script, 'w') do |f|
@@ -151,12 +170,16 @@ Chake.nodes.each do |node|
151
170
 
152
171
  desc "converge #{hostname}"
153
172
  task "converge:#{hostname}" => converge_dependencies do
154
- node.converge
173
+ maybe_decrypt(node) do
174
+ node.converge
175
+ end
155
176
  end
156
177
 
157
178
  desc 'apply <recipe> on #{hostname}'
158
179
  task "apply:#{hostname}", [:recipe] => %i[recipe_input connect_common] do |_task, _args|
159
- node.apply($recipe_to_apply)
180
+ maybe_decrypt(node) do
181
+ node.apply($recipe_to_apply)
182
+ end
160
183
  end
161
184
  task "apply:#{hostname}" => converge_dependencies
162
185
 
@@ -0,0 +1,4 @@
1
+ # chef-solo already installed
2
+ if which chef-solo >/dev/null 2>&1; then
3
+ exit
4
+ fi
@@ -30,10 +30,6 @@ module Chake
30
30
  steps.sort_by { |f| File.basename(f) }
31
31
  end
32
32
 
33
- def needs_bootstrap?
34
- true
35
- end
36
-
37
33
  def needs_upload?
38
34
  true
39
35
  end
@@ -13,10 +13,6 @@ module Chake
13
13
  run_itamae(config)
14
14
  end
15
15
 
16
- def needs_bootstrap?
17
- false
18
- end
19
-
20
16
  def needs_upload?
21
17
  false
22
18
  end
@@ -39,6 +35,9 @@ module Chake
39
35
  raise NotImplementedError, "Connection type #{node.connection.class} not supported for itamee"
40
36
  end
41
37
  cmd << "--node-json=#{json_config}"
38
+ if node.silent
39
+ cmd << '--log-level=warn'
40
+ end
42
41
  cmd += recipes
43
42
  node.log("$ #{cmd.join(' ')}")
44
43
  io = IO.popen(cmd, 'r', err: %i[child out])
@@ -43,7 +43,7 @@ module Chake
43
43
  @config_manager ||= Chake::ConfigManager.get(self)
44
44
  end
45
45
 
46
- def_delegators :config_manager, :converge, :apply, :path, :bootstrap_steps, :needs_bootstrap?, :needs_upload?
46
+ def_delegators :config_manager, :converge, :apply, :path, :bootstrap_steps, :needs_upload?
47
47
 
48
48
  def path
49
49
  @path ||= config_manager.path
@@ -1,3 +1,3 @@
1
1
  module Chake
2
- VERSION = '0.80'.freeze
2
+ VERSION = '0.81'.freeze
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'singleton'
2
+
3
+ module Chake
4
+ class Wipe
5
+ include Singleton
6
+
7
+ if system('which', 'wipe', out: '/dev/null', err: :out)
8
+ def wipe(file)
9
+ system('wipe', '-rfs', file)
10
+ end
11
+ else
12
+ warn 'W: please install "wipe" program for secure deletion, falling back to unlink(2)'
13
+ def wipe(file)
14
+ File.unlink(file)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -15,6 +15,7 @@ MANPAGES.each do |man|
15
15
  sh "sed -f man/readme2man.sed #{source} > #{man}.ronn || (rm -f #{man}.ronn; false)"
16
16
  sh "ronn --roff #{man}.ronn"
17
17
  sh "rm -f #{man}.ronn"
18
+ sh 'sed', '-i', '-e', 's/\\\\\'/\'/', man
18
19
  end
19
20
  end
20
21
 
@@ -1,3 +1,4 @@
1
+ require 'spec_helper'
1
2
  require 'chake/node'
2
3
  require 'chake/config_manager/itamae'
3
4
 
@@ -12,10 +13,6 @@ describe Chake::ConfigManager::Itamae do
12
13
  let(:cfg) { Chake::ConfigManager::Itamae.new(node) }
13
14
  let(:output) { StringIO.new("line1\nline2\n") }
14
15
 
15
- it 'does not require bootstrapping' do
16
- expect(cfg.needs_bootstrap?).to eq(false)
17
- end
18
-
19
16
  it 'does not require uploading' do
20
17
  expect(cfg.needs_upload?).to eq(false)
21
18
  end
@@ -54,7 +51,7 @@ describe Chake::ConfigManager::Itamae do
54
51
  let(:hostname) { 'local://localhostname' }
55
52
  it 'calls itamae with local subcommand' do
56
53
  expect(IO).to receive(:popen).with(
57
- ['itamae', 'local', /--node-json=.*/, 'foo.rb', 'bar.rb'],
54
+ array_including('itamae', 'local', /--node-json=.*/, 'foo.rb', 'bar.rb'),
58
55
  anything,
59
56
  err: anything
60
57
  ).and_return(output)
@@ -66,4 +63,25 @@ describe Chake::ConfigManager::Itamae do
66
63
  allow(node).to receive(:connection).and_return(Object.new)
67
64
  expect(-> { cfg.converge }).to raise_error(NotImplementedError)
68
65
  end
66
+
67
+ it 'handles silent mode' do
68
+ expect(IO).to receive(:popen).with(
69
+ array_including('--log-level=warn'),
70
+ anything,
71
+ err: anything
72
+ ).and_return(output)
73
+ cfg.converge
74
+ end
75
+
76
+ RSpec::Matchers.define_negated_matcher :array_excluding, :include
77
+
78
+ it 'handles non-silent mode' do
79
+ node.silent = false
80
+ expect(IO).to receive(:popen).with(
81
+ array_excluding('--log-level=warn'),
82
+ anything,
83
+ err: anything
84
+ ).and_return(output)
85
+ silence($stdout) { cfg.converge }
86
+ end
69
87
  end
@@ -17,8 +17,7 @@ describe Chake::ConfigManager do
17
17
  end
18
18
  end
19
19
 
20
- it 'requires uploading and bootstrapping by default' do
20
+ it 'requires uploading by default' do
21
21
  expect(subject.needs_upload?).to eq(true)
22
- expect(subject.needs_bootstrap?).to eq(true)
23
22
  end
24
23
  end
@@ -44,3 +44,21 @@ shared_examples 'Chake::Connection' do |connection_class|
44
44
  connection.run_as_root('something')
45
45
  end
46
46
  end
47
+
48
+ module Helpers
49
+ def silence(stream)
50
+ orig_stream = stream.clone
51
+ begin
52
+ File.open('/dev/null', 'w') do |f|
53
+ stream.reopen(f)
54
+ yield
55
+ end
56
+ ensure
57
+ stream.reopen(orig_stream)
58
+ end
59
+ end
60
+ end
61
+
62
+ RSpec.configure do |c|
63
+ c.include Helpers
64
+ end
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.80'
4
+ version: '0.81'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Terceiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-12 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,7 +133,8 @@ files:
133
133
  - examples/test/cookbooks/example/recipes/default.rb
134
134
  - lib/chake.rb
135
135
  - lib/chake/bootstrap/00_set_hostname.sh
136
- - lib/chake/bootstrap/chef/01_debian.sh
136
+ - lib/chake/bootstrap/chef/01_installed.sh
137
+ - lib/chake/bootstrap/chef/02_debian.sh
137
138
  - lib/chake/bootstrap/chef/99_unsupported.sh
138
139
  - lib/chake/config.rb
139
140
  - lib/chake/config_manager.rb
@@ -157,6 +158,7 @@ files:
157
158
  - lib/chake/readline.rb
158
159
  - lib/chake/tmpdir.rb
159
160
  - lib/chake/version.rb
161
+ - lib/chake/wipe.rb
160
162
  - man/.gitignore
161
163
  - man/Rakefile
162
164
  - man/readme2man.sed