chake 0.82 → 0.90

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: 912ff9a308d2f2d1738b2708fc487dcef50ab241b292e081e3a633b50136ed02
4
- data.tar.gz: aa5819064902a6c70c29274d1d0f08497275f72c787ee2094db73e7c579faf24
3
+ metadata.gz: 73bba733109589908cc9fe35b4f009f105cdac398b8e2eeb4a6ca3638f328276
4
+ data.tar.gz: 715c2eb00007ced85da48fd4c5c4d4ec6c508627494a87aaeb0e25e1dea3968e
5
5
  SHA512:
6
- metadata.gz: a0247ef1aa495a4ecf4c89d716123400f0c16f72d3897378b94923c1e355474fa356ec776c0ee5e2ebc0af271b54fa448b38b5368ff1acfc205ada2199c23029
7
- data.tar.gz: 903e32b0e944b55dafe3a18cc717b30e73d2abf3dd09c0f62850514c9324c14a6d14d7c557a43ab1e2d0fbfc20c085b10b03328d58381f420ff1a62f9b42088e
6
+ metadata.gz: d04fcefd02e1fe73eba0941f2d1dda595f28e1c40067daf74defac1020039812c58740769bebbdcc92f6414c9d49da3b0753f4e088bb4cefaed295432910f1d2
7
+ data.tar.gz: 717537aa7effd7371cc23ba4e1fcaa80fb1a0a47fe97d5123abe69488b4b193b61afb34be806a8314234e2257b60081a4c2229a8c93880977609f1fdea69bea5
data/.manifest CHANGED
@@ -8,6 +8,7 @@ ChangeLog.md
8
8
  Gemfile
9
9
  LICENSE.txt
10
10
  README.chef.md
11
+ README.itamae-remote.md
11
12
  README.itamae.md
12
13
  README.md
13
14
  README.shell.md
@@ -28,10 +29,14 @@ lib/chake/bootstrap/00_set_hostname.sh
28
29
  lib/chake/bootstrap/chef/01_installed.sh
29
30
  lib/chake/bootstrap/chef/02_debian.sh
30
31
  lib/chake/bootstrap/chef/99_unsupported.sh
32
+ lib/chake/bootstrap/itamae-remote/01_installed.sh
33
+ lib/chake/bootstrap/itamae-remote/02_debian.sh
34
+ lib/chake/bootstrap/itamae-remote/99_unsupported.sh
31
35
  lib/chake/config.rb
32
36
  lib/chake/config_manager.rb
33
37
  lib/chake/config_manager/chef.rb
34
38
  lib/chake/config_manager/itamae.rb
39
+ lib/chake/config_manager/itamae_remote.rb
35
40
  lib/chake/config_manager/shell.rb
36
41
  lib/chake/config_manager/skel/chef/Rakefile
37
42
  lib/chake/config_manager/skel/chef/config.rb
@@ -58,6 +63,7 @@ spec/chake/backend/local_spec.rb
58
63
  spec/chake/backend/ssh_spec.rb
59
64
  spec/chake/backend_spec.rb
60
65
  spec/chake/config_manager/chef_spec.rb
66
+ spec/chake/config_manager/itamae_remote_spec.rb
61
67
  spec/chake/config_manager/itamae_spec.rb
62
68
  spec/chake/config_manager/shell_spec.rb
63
69
  spec/chake/config_manager_spec.rb
data/ChangeLog.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.90
2
+
3
+ * itamae: use --sudo when root for local backend
4
+ * Chake::ConfigManager: fix typo
5
+ * chake/config: allow aliases in YAML data
6
+ * codespell: ignore tags file
7
+ * ChangeLog.md: fix typo found by codespell
8
+ * Implement new configuration manager: itamae-remote
9
+
1
10
  # 0.82
2
11
 
3
12
  * gemspec: drop bundler version constraint
@@ -23,7 +32,7 @@ This release adds support for multiple configuration managers. Chef is now only
23
32
  one of the options. There is also now support for configuration management with
24
33
  itamae, and lightweight configuration management tool inspired by Chef, and via
25
34
  shell commands. This should be mostly transparent to current Chef users, but
26
- new repositories initiatied by chake will use itamae by default.
35
+ new repositories initiated by chake will use itamae by default.
27
36
 
28
37
  Other notable changes:
29
38
 
@@ -0,0 +1,61 @@
1
+ chake-itamae-remote(7) -- configure chake nodes with a remote itamae
2
+ ====================================================================
3
+
4
+ ## Description
5
+
6
+ This configuration manager will run **itamae(1)** on each remote node. This is
7
+ different from the _itamae_ configuration manager, which runs itamae on your
8
+ workstation (the host running chake). _itamae-remote_ will run itamae
9
+ individually on each node, which is one order of magnitude faster. This
10
+ requires itamae to be installed on each node, and that will be taken care of
11
+ automatically by the bootstrapping process.
12
+
13
+ ## Configuration
14
+
15
+ The _itamae-remote_ configuration manager requires one key called
16
+ `itamae-remote`, and the value must be a list of strings representing the list
17
+ of recipes to apply to the node when converging.
18
+
19
+ ```yaml
20
+ host1.mycompany.com:
21
+ itamae-remote:
22
+ - cookbooks/basic/default.rb
23
+ - roles/server.rb
24
+ service1:
25
+ option1: "here we go"
26
+ ```
27
+
28
+ Any extra configuration under `host1.mycompany.com` will be saved to a JSON file
29
+ and given to the itamae --node-json option in the command line. For example,
30
+ the above configuration will produce a JSON file that looks like this:
31
+
32
+ ```json
33
+ {
34
+ "itamae": [
35
+ "cookbooks/basic.rb",
36
+ "roles/server.rb"
37
+ ]
38
+ ,
39
+ "service1": {
40
+ "option1": "here we go"
41
+ }
42
+ }
43
+ ```
44
+
45
+ Inside itamae recipes, you can access those values by using the `node` object.
46
+ For example:
47
+
48
+ ```ruby
49
+ template "/etc/service1.conf.d/option1.conf" do
50
+ variables option1: node["option1"]
51
+ end
52
+ ```
53
+
54
+ ## Bootstrapping
55
+
56
+ The bootstrapping process will make sure itamae is installed. The node hostname
57
+ will be set according to your chake configuration.
58
+
59
+ ## See also
60
+
61
+ * **chake(1)**
data/Rakefile CHANGED
@@ -102,7 +102,7 @@ end
102
102
 
103
103
  desc 'Check spelling in the source code'
104
104
  task :codespell do
105
- sh 'codespell', '--skip=.git', '--skip=coverage', '--skip=*.asc', '--skip=*.swp'
105
+ sh 'codespell', '--skip=.git', '--skip=coverage', '--skip=*.asc', '--skip=*.swp', '--skip=tags'
106
106
  end
107
107
 
108
108
  task default: [:test, :style, :codespell]
@@ -0,0 +1,4 @@
1
+ # itamae already installed
2
+ if which itamae >/dev/null 2>&1; then
3
+ exit
4
+ fi
@@ -0,0 +1,6 @@
1
+ if [ -x /usr/bin/apt-get ]; then
2
+ apt-get update
3
+ export DEBIAN_FRONTEND=noninteractive
4
+ apt-get -q -y install rsync itamae
5
+ exit
6
+ fi
@@ -0,0 +1,16 @@
1
+ echo "---------------------"
2
+ echo "Unsupported platform: Installing itamae with rubygems"
3
+ echo "---------------------"
4
+ echo
5
+
6
+ for file in /etc/os-release /etc/issue; do
7
+ if [ -f $file ]; then
8
+ cat $file
9
+ break
10
+ fi
11
+ done
12
+
13
+ if ! which itamae >/dev/null ; then
14
+ gem install itamae
15
+ exit
16
+ fi
data/lib/chake/config.rb CHANGED
@@ -8,12 +8,12 @@ end
8
8
 
9
9
  nodes_file = ENV['CHAKE_NODES'] || 'nodes.yaml'
10
10
  nodes_directory = ENV['CHAKE_NODES_D'] || 'nodes.d'
11
- nodes = File.exist?(nodes_file) && YAML.load_file(nodes_file) || {}
11
+ nodes = File.exist?(nodes_file) && YAML.load_file(nodes_file, aliases: true) || {}
12
12
  nodes.values.each do |node|
13
13
  node['chake_metadata'] = { 'definition_file' => nodes_file }
14
14
  end
15
15
  Dir.glob(File.join(nodes_directory, '*.yaml')).sort.each do |f|
16
- file_nodes = YAML.load_file(f)
16
+ file_nodes = YAML.load_file(f, aliases: true)
17
17
  file_nodes.values.each do |node|
18
18
  node['chake_metadata'] = { 'definition_file' => f }
19
19
  end
@@ -30,6 +30,9 @@ module Chake
30
30
  cmd << 'ssh' << "--user=#{node.username}" << "--host=#{node.hostname}"
31
31
  cmd += ssh_config
32
32
  when Chake::Connection::Local
33
+ if node.username == 'root'
34
+ cmd.prepend 'sudo'
35
+ end
33
36
  cmd << 'local'
34
37
  else
35
38
  raise NotImplementedError, "Connection type #{node.connection.class} not supported for itamee"
@@ -0,0 +1,40 @@
1
+ require 'shellwords'
2
+ require 'chake/config'
3
+ require 'chake/tmpdir'
4
+
5
+ module Chake
6
+ class ConfigManager
7
+ class ItamaeRemote < ConfigManager
8
+ def converge
9
+ run_itamae(*node.data['itamae-remote'])
10
+ end
11
+
12
+ def apply(config)
13
+ run_itamae(config)
14
+ end
15
+
16
+ def needs_upload?
17
+ true
18
+ end
19
+
20
+ def self.accept?(node)
21
+ node.data.key?('itamae-remote')
22
+ end
23
+
24
+ private
25
+
26
+ def run_itamae(*recipes)
27
+ cmd = ['itamae', 'local', "--node-json=#{json_config}"]
28
+ if node.silent
29
+ cmd << '--log-level=warn'
30
+ end
31
+ cmd += recipes.map { |r| File.join(node.path, r) }
32
+ node.run_as_root(Shellwords.join(cmd))
33
+ end
34
+
35
+ def json_config
36
+ File.join(node.path, Chake.tmpdir, "#{node.hostname}.json")
37
+ end
38
+ end
39
+ end
40
+ end
@@ -35,11 +35,15 @@ module Chake
35
35
  end
36
36
 
37
37
  def self.short_name
38
- name.split('::').last.downcase
38
+ name.split('::').last.gsub(/([[:lower:]])([[:upper:]])/) do
39
+ first = Regexp.last_match(1)
40
+ last = Regexp.last_match(2).downcase
41
+ "#{first}-#{last}"
42
+ end.downcase
39
43
  end
40
44
 
41
- def self.priority(new_prioriry = nil)
42
- @priority ||= new_prioriry || 50
45
+ def self.priority(new_priority = nil)
46
+ @priority ||= new_priority || 50
43
47
  end
44
48
 
45
49
  def self.inherited(klass)
data/lib/chake/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chake
2
- VERSION = '0.82'.freeze
2
+ VERSION = '0.90'.freeze
3
3
  end
data/man/Rakefile CHANGED
@@ -2,6 +2,7 @@ MAIN_MANPAGE = 'man/chake.1'.freeze
2
2
  OTHER_MANPAGES = %w[
3
3
  man/chake-chef.7
4
4
  man/chake-itamae.7
5
+ man/chake-itamae-remote.7
5
6
  man/chake-shell.7
6
7
  ].freeze
7
8
  MANPAGES = [MAIN_MANPAGE] + OTHER_MANPAGES
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'chake/node'
3
+ require 'chake/config_manager/itamae_remote'
4
+
5
+ describe Chake::ConfigManager::ItamaeRemote do
6
+ let(:node) do
7
+ Chake::Node.new('somehost').tap do |n|
8
+ n.silent = true
9
+ n.data['itamae-remote'] = ['foo.rb', 'bar.rb']
10
+ end
11
+ end
12
+ let(:cfg) { Chake::ConfigManager.get(node) }
13
+
14
+ it 'is detected correctly' do
15
+ expect(cfg).to be_a(Chake::ConfigManager::ItamaeRemote)
16
+ end
17
+
18
+ it 'requires uploading' do
19
+ expect(cfg.needs_upload?).to eq(true)
20
+ end
21
+
22
+ it 'calls itamae remotely to converge' do
23
+ expect(node).to receive(:run_as_root).with(
24
+ a_string_matching(%r{itamae.*#{node.path}/foo.rb.*#{node.path}/bar.rb})
25
+ )
26
+ cfg.converge
27
+ end
28
+
29
+ it 'calls itamae remotely to apply' do
30
+ expect(node).to receive(:run_as_root).with(
31
+ a_string_matching(%r{itamae.*#{node.path}/doit.rb})
32
+ )
33
+ cfg.apply('doit.rb')
34
+ end
35
+
36
+ it 'handles silent mode' do
37
+ node.silent = true
38
+ expect(node).to receive(:run_as_root).with(
39
+ a_string_matching(/--log-level\\=warn/)
40
+ )
41
+ cfg.converge
42
+ end
43
+
44
+ it 'has a name with dashes' do
45
+ expect(cfg.name).to eq('itamae-remote')
46
+ end
47
+ 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.82'
4
+ version: '0.90'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antonio Terceiro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,6 +116,7 @@ files:
116
116
  - Gemfile
117
117
  - LICENSE.txt
118
118
  - README.chef.md
119
+ - README.itamae-remote.md
119
120
  - README.itamae.md
120
121
  - README.md
121
122
  - README.shell.md
@@ -136,10 +137,14 @@ files:
136
137
  - lib/chake/bootstrap/chef/01_installed.sh
137
138
  - lib/chake/bootstrap/chef/02_debian.sh
138
139
  - lib/chake/bootstrap/chef/99_unsupported.sh
140
+ - lib/chake/bootstrap/itamae-remote/01_installed.sh
141
+ - lib/chake/bootstrap/itamae-remote/02_debian.sh
142
+ - lib/chake/bootstrap/itamae-remote/99_unsupported.sh
139
143
  - lib/chake/config.rb
140
144
  - lib/chake/config_manager.rb
141
145
  - lib/chake/config_manager/chef.rb
142
146
  - lib/chake/config_manager/itamae.rb
147
+ - lib/chake/config_manager/itamae_remote.rb
143
148
  - lib/chake/config_manager/shell.rb
144
149
  - lib/chake/config_manager/skel/chef/Rakefile
145
150
  - lib/chake/config_manager/skel/chef/config.rb
@@ -166,6 +171,7 @@ files:
166
171
  - spec/chake/backend/ssh_spec.rb
167
172
  - spec/chake/backend_spec.rb
168
173
  - spec/chake/config_manager/chef_spec.rb
174
+ - spec/chake/config_manager/itamae_remote_spec.rb
169
175
  - spec/chake/config_manager/itamae_spec.rb
170
176
  - spec/chake/config_manager/shell_spec.rb
171
177
  - spec/chake/config_manager_spec.rb
@@ -175,7 +181,7 @@ homepage: https://gitlab.com/terceiro/chake
175
181
  licenses:
176
182
  - MIT
177
183
  metadata: {}
178
- post_install_message:
184
+ post_install_message:
179
185
  rdoc_options: []
180
186
  require_paths:
181
187
  - lib
@@ -190,8 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
196
  - !ruby/object:Gem::Version
191
197
  version: '0'
192
198
  requirements: []
193
- rubygems_version: 3.2.5
194
- signing_key:
199
+ rubygems_version: 3.3.15
200
+ signing_key:
195
201
  specification_version: 4
196
202
  summary: serverless configuration management tool for chef
197
203
  test_files:
@@ -199,6 +205,7 @@ test_files:
199
205
  - spec/chake/backend/ssh_spec.rb
200
206
  - spec/chake/backend_spec.rb
201
207
  - spec/chake/config_manager/chef_spec.rb
208
+ - spec/chake/config_manager/itamae_remote_spec.rb
202
209
  - spec/chake/config_manager/itamae_spec.rb
203
210
  - spec/chake/config_manager/shell_spec.rb
204
211
  - spec/chake/config_manager_spec.rb