chake 0.82 → 0.90.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.manifest +8 -0
- data/ChangeLog.md +14 -1
- data/README.itamae-remote.md +61 -0
- data/Rakefile +1 -1
- data/lib/chake/bootstrap/itamae-remote/01_installed.sh +4 -0
- data/lib/chake/bootstrap/itamae-remote/02_debian.sh +6 -0
- data/lib/chake/bootstrap/itamae-remote/99_unsupported.sh +16 -0
- data/lib/chake/config.rb +3 -2
- data/lib/chake/config_manager/itamae.rb +3 -0
- data/lib/chake/config_manager/itamae_remote.rb +40 -0
- data/lib/chake/config_manager.rb +7 -3
- data/lib/chake/version.rb +1 -1
- data/lib/chake/yaml.rb +13 -0
- data/man/Rakefile +1 -0
- data/spec/chake/config_manager/itamae_remote_spec.rb +47 -0
- data/spec/integration_tests_spec.rb +48 -0
- metadata +16 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aea493f81d004a6dbcc2ccb1657dd6705d538512e0d7522d9db7e4a7483846fb
|
4
|
+
data.tar.gz: e8a6f9c7e034e95f536361b58ce5083d9f3f3d3037d90e82f7d79ff4c8b389e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e93294e8a34232bd6e709440f3384223e2171a93a280708568e019dbbcaeeeac75de1d0d933e1ccbfd720a34e835a211bf6f51cd707fe241f0a04e2e44f8700f
|
7
|
+
data.tar.gz: 04e65daf9f089b5b9a63e2d097c6a178b0362cf433698310cf9858085967ef026ab2c5775f8eb4eb9339298e1c6281062c05b9a59413b59075fdfb378eec286d
|
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
|
@@ -51,6 +56,7 @@ lib/chake/readline.rb
|
|
51
56
|
lib/chake/tmpdir.rb
|
52
57
|
lib/chake/version.rb
|
53
58
|
lib/chake/wipe.rb
|
59
|
+
lib/chake/yaml.rb
|
54
60
|
man/.gitignore
|
55
61
|
man/Rakefile
|
56
62
|
man/readme2man.sed
|
@@ -58,8 +64,10 @@ spec/chake/backend/local_spec.rb
|
|
58
64
|
spec/chake/backend/ssh_spec.rb
|
59
65
|
spec/chake/backend_spec.rb
|
60
66
|
spec/chake/config_manager/chef_spec.rb
|
67
|
+
spec/chake/config_manager/itamae_remote_spec.rb
|
61
68
|
spec/chake/config_manager/itamae_spec.rb
|
62
69
|
spec/chake/config_manager/shell_spec.rb
|
63
70
|
spec/chake/config_manager_spec.rb
|
64
71
|
spec/chake/node_spec.rb
|
72
|
+
spec/integration_tests_spec.rb
|
65
73
|
spec/spec_helper.rb
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 0.90.1
|
2
|
+
|
3
|
+
* Fix loading node data under ruby < 3.1
|
4
|
+
|
5
|
+
# 0.90
|
6
|
+
|
7
|
+
* itamae: use --sudo when root for local backend
|
8
|
+
* Chake::ConfigManager: fix typo
|
9
|
+
* chake/config: allow aliases in YAML data
|
10
|
+
* codespell: ignore tags file
|
11
|
+
* ChangeLog.md: fix typo found by codespell
|
12
|
+
* Implement new configuration manager: itamae-remote
|
13
|
+
|
1
14
|
# 0.82
|
2
15
|
|
3
16
|
* gemspec: drop bundler version constraint
|
@@ -23,7 +36,7 @@ This release adds support for multiple configuration managers. Chef is now only
|
|
23
36
|
one of the options. There is also now support for configuration management with
|
24
37
|
itamae, and lightweight configuration management tool inspired by Chef, and via
|
25
38
|
shell commands. This should be mostly transparent to current Chef users, but
|
26
|
-
new repositories
|
39
|
+
new repositories initiated by chake will use itamae by default.
|
27
40
|
|
28
41
|
Other notable changes:
|
29
42
|
|
@@ -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,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
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'chake/node'
|
2
|
+
require 'chake/yaml'
|
2
3
|
|
3
4
|
module Chake
|
4
5
|
class << self
|
@@ -8,12 +9,12 @@ end
|
|
8
9
|
|
9
10
|
nodes_file = ENV['CHAKE_NODES'] || 'nodes.yaml'
|
10
11
|
nodes_directory = ENV['CHAKE_NODES_D'] || 'nodes.d'
|
11
|
-
nodes = File.exist?(nodes_file) && YAML.load_file(nodes_file) || {}
|
12
|
+
nodes = File.exist?(nodes_file) && Chake::YAML.load_file(nodes_file) || {}
|
12
13
|
nodes.values.each do |node|
|
13
14
|
node['chake_metadata'] = { 'definition_file' => nodes_file }
|
14
15
|
end
|
15
16
|
Dir.glob(File.join(nodes_directory, '*.yaml')).sort.each do |f|
|
16
|
-
file_nodes = YAML.load_file(f)
|
17
|
+
file_nodes = Chake::YAML.load_file(f)
|
17
18
|
file_nodes.values.each do |node|
|
18
19
|
node['chake_metadata'] = { 'definition_file' => f }
|
19
20
|
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
|
data/lib/chake/config_manager.rb
CHANGED
@@ -35,11 +35,15 @@ module Chake
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.short_name
|
38
|
-
name.split('::').last.
|
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(
|
42
|
-
@priority ||=
|
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
data/lib/chake/yaml.rb
ADDED
data/man/Rakefile
CHANGED
@@ -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
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'pathname'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
describe 'Chake' do
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
def sh(*args)
|
9
|
+
cmd = Shellwords.join(args)
|
10
|
+
lib = [Pathname.new(__FILE__).parent.parent / 'lib', ENV['RUBYLIB']].compact.join(':')
|
11
|
+
path = [Pathname.new(__FILE__).parent.parent / 'bin', ENV['PATH']].join(':')
|
12
|
+
env = {
|
13
|
+
'RUBYLIB' => lib,
|
14
|
+
'PATH' => path
|
15
|
+
}
|
16
|
+
unless system(env, *args, out: ['.out', 'w'], err: ['.err', 'w'])
|
17
|
+
out = File.read('.out')
|
18
|
+
err = File.read('.err')
|
19
|
+
raise "Command [#{cmd}] failed with exit status #{$CHILD_STATUS} (PATH = #{path}, RUBYLIB = #{lib}).\nstdout:\n#{out}\nstderr:\n#{err}"
|
20
|
+
end
|
21
|
+
rm_f '.log'
|
22
|
+
end
|
23
|
+
|
24
|
+
def chake(*args)
|
25
|
+
cmd = [Gem.ruby, '-S', 'chake'] + args
|
26
|
+
sh(*cmd)
|
27
|
+
end
|
28
|
+
|
29
|
+
def rake(*args)
|
30
|
+
cmd = [Gem.ruby, '-S', 'rake'] + args
|
31
|
+
sh(*cmd)
|
32
|
+
end
|
33
|
+
|
34
|
+
def project
|
35
|
+
Dir.mktmpdir do |dir|
|
36
|
+
Dir.chdir(dir) do
|
37
|
+
yield dir
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'loads node information' do
|
43
|
+
project do
|
44
|
+
chake 'init'
|
45
|
+
rake 'nodes'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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:
|
4
|
+
version: 0.90.1
|
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:
|
11
|
+
date: 2022-12-18 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
|
@@ -159,6 +164,7 @@ files:
|
|
159
164
|
- lib/chake/tmpdir.rb
|
160
165
|
- lib/chake/version.rb
|
161
166
|
- lib/chake/wipe.rb
|
167
|
+
- lib/chake/yaml.rb
|
162
168
|
- man/.gitignore
|
163
169
|
- man/Rakefile
|
164
170
|
- man/readme2man.sed
|
@@ -166,16 +172,18 @@ files:
|
|
166
172
|
- spec/chake/backend/ssh_spec.rb
|
167
173
|
- spec/chake/backend_spec.rb
|
168
174
|
- spec/chake/config_manager/chef_spec.rb
|
175
|
+
- spec/chake/config_manager/itamae_remote_spec.rb
|
169
176
|
- spec/chake/config_manager/itamae_spec.rb
|
170
177
|
- spec/chake/config_manager/shell_spec.rb
|
171
178
|
- spec/chake/config_manager_spec.rb
|
172
179
|
- spec/chake/node_spec.rb
|
180
|
+
- spec/integration_tests_spec.rb
|
173
181
|
- spec/spec_helper.rb
|
174
182
|
homepage: https://gitlab.com/terceiro/chake
|
175
183
|
licenses:
|
176
184
|
- MIT
|
177
185
|
metadata: {}
|
178
|
-
post_install_message:
|
186
|
+
post_install_message:
|
179
187
|
rdoc_options: []
|
180
188
|
require_paths:
|
181
189
|
- lib
|
@@ -190,8 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
198
|
- !ruby/object:Gem::Version
|
191
199
|
version: '0'
|
192
200
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
194
|
-
signing_key:
|
201
|
+
rubygems_version: 3.3.15
|
202
|
+
signing_key:
|
195
203
|
specification_version: 4
|
196
204
|
summary: serverless configuration management tool for chef
|
197
205
|
test_files:
|
@@ -199,8 +207,10 @@ test_files:
|
|
199
207
|
- spec/chake/backend/ssh_spec.rb
|
200
208
|
- spec/chake/backend_spec.rb
|
201
209
|
- spec/chake/config_manager/chef_spec.rb
|
210
|
+
- spec/chake/config_manager/itamae_remote_spec.rb
|
202
211
|
- spec/chake/config_manager/itamae_spec.rb
|
203
212
|
- spec/chake/config_manager/shell_spec.rb
|
204
213
|
- spec/chake/config_manager_spec.rb
|
205
214
|
- spec/chake/node_spec.rb
|
215
|
+
- spec/integration_tests_spec.rb
|
206
216
|
- spec/spec_helper.rb
|