chake 0.19 → 0.80
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/.ackrc +1 -0
- data/.gitignore +2 -0
- data/.gitlab-ci.yml +21 -9
- data/.manifest +63 -0
- data/.rubocop.yml +53 -0
- data/.rubocop_todo.yml +40 -0
- data/ChangeLog.md +36 -0
- data/README.chef.md +70 -0
- data/README.itamae.md +58 -0
- data/README.md +124 -85
- data/README.shell.md +30 -0
- data/Rakefile +40 -13
- data/bin/chake +12 -1
- data/chake.gemspec +16 -16
- data/examples/test/.ssh_config +4 -0
- data/examples/test/Rakefile +1 -1
- data/examples/test/Vagrantfile +6 -0
- data/examples/test/config.rb +4 -4
- data/examples/test/cookbooks/basics/recipes/default.rb +1 -0
- data/examples/test/cookbooks/example/files/default/test +1 -0
- data/examples/test/cookbooks/example/files/{host-homer → host-lemur}/test.asc +0 -0
- data/lib/chake.rb +92 -168
- data/lib/chake/bootstrap/{01_debian.sh → chef/01_debian.sh} +0 -0
- data/lib/chake/bootstrap/{99_unsupported.sh → chef/99_unsupported.sh} +0 -0
- data/lib/chake/config.rb +16 -0
- data/lib/chake/config_manager.rb +93 -0
- data/lib/chake/config_manager/chef.rb +35 -0
- data/lib/chake/config_manager/itamae.rb +58 -0
- data/lib/chake/config_manager/shell.rb +34 -0
- data/lib/chake/config_manager/skel/chef/Rakefile +1 -0
- data/lib/chake/config_manager/skel/chef/config.rb +4 -0
- data/lib/chake/config_manager/skel/chef/cookbooks/basics/recipes/default.rb +1 -0
- data/lib/chake/config_manager/skel/chef/nodes.yaml +3 -0
- data/lib/chake/config_manager/skel/itamae/Rakefile +1 -0
- data/lib/chake/config_manager/skel/itamae/cookbooks/basics/default.rb +1 -0
- data/lib/chake/config_manager/skel/itamae/nodes.yaml +3 -0
- data/lib/chake/config_manager/skel/itamae/roles/basic.rb +1 -0
- data/lib/chake/config_manager/skel/shell/Rakefile +1 -0
- data/lib/chake/config_manager/skel/shell/nodes.yaml +3 -0
- data/lib/chake/connection.rb +83 -0
- data/lib/chake/{backend → connection}/local.rb +2 -8
- data/lib/chake/{backend → connection}/ssh.rb +6 -14
- data/lib/chake/node.rb +49 -29
- data/lib/chake/readline.rb +6 -10
- data/lib/chake/version.rb +1 -1
- data/man/Rakefile +27 -14
- data/man/readme2man.sed +5 -5
- data/spec/chake/backend/local_spec.rb +5 -6
- data/spec/chake/backend/ssh_spec.rb +8 -10
- data/spec/chake/backend_spec.rb +1 -2
- data/spec/chake/config_manager/chef_spec.rb +38 -0
- data/spec/chake/config_manager/itamae_spec.rb +69 -0
- data/spec/chake/config_manager/shell_spec.rb +54 -0
- data/spec/chake/config_manager_spec.rb +24 -0
- data/spec/chake/node_spec.rb +38 -15
- data/spec/spec_helper.rb +23 -19
- metadata +61 -14
- data/lib/chake/backend.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0276e69503885ac871f9c3b73025598fe4401dd361e78e90d5921a873395a9b
|
4
|
+
data.tar.gz: 5e132b6715fb2f087ecfd72a411c8ab371f1bb0da63f7bf74def69e1c028fd15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0914e13f840deaaba8a80eb7052006659e023ba8ea0c53aad08416cd56bedd2b66807f939352a7e57f53dad28cdcba5241884db461252dd909b4b09902d5d45f'
|
7
|
+
data.tar.gz: a0de67988cecfde1355cf0ebe21b778cb0fa51db7c6d572965ab34a2bb6eed43c88db7a8ef4eddf4f595344fc5685a2f11e67691ec82e90a81de314b15e39e90
|
data/.ackrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--ignore-dir=coverage
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
-
|
1
|
+
image: debian:testing
|
2
|
+
|
3
|
+
.install: &install
|
4
|
+
- apt-get update && apt-get install -qy ruby asciidoctor ruby-bundler ruby-rspec rubocop ruby-simplecov codespell
|
5
5
|
|
6
6
|
tests:
|
7
|
+
before_script: *install
|
8
|
+
script:
|
9
|
+
- rake test
|
10
|
+
|
11
|
+
manpages:
|
12
|
+
before_script: *install
|
13
|
+
script:
|
14
|
+
- rake man
|
15
|
+
|
16
|
+
style:
|
17
|
+
before_script: *install
|
18
|
+
script:
|
19
|
+
- rake style
|
20
|
+
|
21
|
+
codespell:
|
22
|
+
before_script: *install
|
7
23
|
script:
|
8
|
-
-
|
9
|
-
- bundle exec rake -f man/Rakefile
|
10
|
-
cache:
|
11
|
-
paths:
|
12
|
-
- .bundle
|
24
|
+
- rake codespell
|
data/.manifest
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
.ackrc
|
2
|
+
.gitignore
|
3
|
+
.gitlab-ci.yml
|
4
|
+
.manifest
|
5
|
+
.rubocop.yml
|
6
|
+
.rubocop_todo.yml
|
7
|
+
ChangeLog.md
|
8
|
+
Gemfile
|
9
|
+
LICENSE.txt
|
10
|
+
README.chef.md
|
11
|
+
README.itamae.md
|
12
|
+
README.md
|
13
|
+
README.shell.md
|
14
|
+
Rakefile
|
15
|
+
bin/chake
|
16
|
+
chake.gemspec
|
17
|
+
chake.spec.erb
|
18
|
+
examples/test/.ssh_config
|
19
|
+
examples/test/Rakefile
|
20
|
+
examples/test/Vagrantfile
|
21
|
+
examples/test/config.rb
|
22
|
+
examples/test/cookbooks/basics/recipes/default.rb
|
23
|
+
examples/test/cookbooks/example/files/default/test
|
24
|
+
examples/test/cookbooks/example/files/host-lemur/test.asc
|
25
|
+
examples/test/cookbooks/example/recipes/default.rb
|
26
|
+
lib/chake.rb
|
27
|
+
lib/chake/bootstrap/00_set_hostname.sh
|
28
|
+
lib/chake/bootstrap/chef/01_debian.sh
|
29
|
+
lib/chake/bootstrap/chef/99_unsupported.sh
|
30
|
+
lib/chake/config.rb
|
31
|
+
lib/chake/config_manager.rb
|
32
|
+
lib/chake/config_manager/chef.rb
|
33
|
+
lib/chake/config_manager/itamae.rb
|
34
|
+
lib/chake/config_manager/shell.rb
|
35
|
+
lib/chake/config_manager/skel/chef/Rakefile
|
36
|
+
lib/chake/config_manager/skel/chef/config.rb
|
37
|
+
lib/chake/config_manager/skel/chef/cookbooks/basics/recipes/default.rb
|
38
|
+
lib/chake/config_manager/skel/chef/nodes.yaml
|
39
|
+
lib/chake/config_manager/skel/itamae/Rakefile
|
40
|
+
lib/chake/config_manager/skel/itamae/cookbooks/basics/default.rb
|
41
|
+
lib/chake/config_manager/skel/itamae/nodes.yaml
|
42
|
+
lib/chake/config_manager/skel/itamae/roles/basic.rb
|
43
|
+
lib/chake/config_manager/skel/shell/Rakefile
|
44
|
+
lib/chake/config_manager/skel/shell/nodes.yaml
|
45
|
+
lib/chake/connection.rb
|
46
|
+
lib/chake/connection/local.rb
|
47
|
+
lib/chake/connection/ssh.rb
|
48
|
+
lib/chake/node.rb
|
49
|
+
lib/chake/readline.rb
|
50
|
+
lib/chake/tmpdir.rb
|
51
|
+
lib/chake/version.rb
|
52
|
+
man/.gitignore
|
53
|
+
man/Rakefile
|
54
|
+
man/readme2man.sed
|
55
|
+
spec/chake/backend/local_spec.rb
|
56
|
+
spec/chake/backend/ssh_spec.rb
|
57
|
+
spec/chake/backend_spec.rb
|
58
|
+
spec/chake/config_manager/chef_spec.rb
|
59
|
+
spec/chake/config_manager/itamae_spec.rb
|
60
|
+
spec/chake/config_manager/shell_spec.rb
|
61
|
+
spec/chake/config_manager_spec.rb
|
62
|
+
spec/chake/node_spec.rb
|
63
|
+
spec/spec_helper.rb
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
NewCops: enable
|
5
|
+
|
6
|
+
Layout/LineLength:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/PerceivedComplexity:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/FormatString:
|
25
|
+
EnforcedStyle: percent
|
26
|
+
|
27
|
+
Style/FrozenStringLiteralComment:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Style/GlobalVars:
|
31
|
+
Exclude:
|
32
|
+
- lib/chake.rb
|
33
|
+
|
34
|
+
Style/GuardClause:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/HashEachMethods:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/HashTransformKeys:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/HashTransformValues:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Style/IfUnlessModifier:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/SymbolArray:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Gemspec/RequiredRubyVersion:
|
53
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-03-25 17:43:43 -0300 using RuboCop version 0.52.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyle.
|
12
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
13
|
+
Layout/HeredocIndentation:
|
14
|
+
Exclude:
|
15
|
+
- 'lib/chake.rb'
|
16
|
+
|
17
|
+
# Offense count: 3
|
18
|
+
Lint/AmbiguousOperator:
|
19
|
+
Exclude:
|
20
|
+
- 'lib/chake.rb'
|
21
|
+
|
22
|
+
# Offense count: 1
|
23
|
+
Lint/InterpolationCheck:
|
24
|
+
Exclude:
|
25
|
+
- 'lib/chake.rb'
|
26
|
+
|
27
|
+
# Offense count: 1
|
28
|
+
# Configuration parameters: Blacklist.
|
29
|
+
# Blacklist: END, (?-mix:EO[A-Z]{1})
|
30
|
+
Naming/HeredocDelimiterNaming:
|
31
|
+
Exclude:
|
32
|
+
- 'lib/chake.rb'
|
33
|
+
|
34
|
+
# Offense count: 1
|
35
|
+
# Cop supports --auto-correct.
|
36
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
37
|
+
# SupportedStyles: nested, compact
|
38
|
+
Style/ClassAndModuleChildren:
|
39
|
+
Exclude:
|
40
|
+
- 'bin/chake'
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
# 0.80
|
2
|
+
|
3
|
+
This release adds support for multiple configuration managers. Chef is now only
|
4
|
+
one of the options. There is also now support for configuration management with
|
5
|
+
itamae, and lightweight configuration management tool inspired by Chef, and via
|
6
|
+
shell commands. This should be mostly transparent to current Chef users, but
|
7
|
+
new repositories initiatied by chake will use itamae by default.
|
8
|
+
|
9
|
+
Other notable changes:
|
10
|
+
|
11
|
+
* rake nodes: list configuration manager and format as table
|
12
|
+
* Chake::Connection: fix handling of stderr
|
13
|
+
* Rebootstrap nodes when changing config managers
|
14
|
+
* bootstrap, upload: skip when config manager does not need them
|
15
|
+
|
16
|
+
# 0.21.2
|
17
|
+
|
18
|
+
* Chake::Backend#run: don't strip leading whitespace
|
19
|
+
|
20
|
+
# 0.21.1
|
21
|
+
|
22
|
+
* Fix converge when the connection is not already made as root. This bug was
|
23
|
+
introduced by the change in the previous release.
|
24
|
+
|
25
|
+
# 0.21
|
26
|
+
|
27
|
+
* converge, apply: allow removing data from the node JSON attributes
|
28
|
+
|
29
|
+
# 0.20
|
30
|
+
|
31
|
+
* check: give some feedback by running `sudo echo OK` instead of `sudo true`
|
32
|
+
* Get rid of global variables
|
33
|
+
* bin/chake: make rake run one thread for each node
|
34
|
+
* Chake::Backend: run commands by opening a shell and writing to it
|
35
|
+
* Document Chake.nodes
|
36
|
+
|
1
37
|
# 0.19
|
2
38
|
|
3
39
|
* Protect node JSON files from other users
|
data/README.chef.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
chake-chef(7) -- configure chake nodes with chef-solo
|
2
|
+
=====================================================
|
3
|
+
|
4
|
+
## Description
|
5
|
+
|
6
|
+
This configuration manager will allow you to manage nodes by running
|
7
|
+
**chef-solo(1)** on each remote node.
|
8
|
+
|
9
|
+
When `chake init` runs, the following chef-specific files will be created:
|
10
|
+
|
11
|
+
A brief explanation of the created files that are specific to **chef**:
|
12
|
+
|
13
|
+
* `config.rb`: contains the chef-solo configuration. You can modify it, but
|
14
|
+
usually you won't need to.
|
15
|
+
* `config/roles`: directory is where you can put your role definitions.
|
16
|
+
* `cookbooks`: directory where you will store your cookbooks. A sample cookbook
|
17
|
+
called "basics" is created, but feel free to remove it and add actual
|
18
|
+
cookbooks.
|
19
|
+
|
20
|
+
## Configuration
|
21
|
+
|
22
|
+
Nodes can be configured to be managed with chef by having a `run_list` key in
|
23
|
+
their configuration:
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
host1.mycompany.com:
|
27
|
+
run_list:
|
28
|
+
- role[server]
|
29
|
+
- recipe[service1]
|
30
|
+
service1:
|
31
|
+
option1: "here we go"
|
32
|
+
```
|
33
|
+
|
34
|
+
Any extra configuration under `host1.mycompany.com` will be saved to a JSON file
|
35
|
+
and given to the chef-solo --node-json option in the command line. For example,
|
36
|
+
the above configuration will produce a JSON file that looks like this:
|
37
|
+
|
38
|
+
```json
|
39
|
+
{
|
40
|
+
"run_list": [
|
41
|
+
"role[server]",
|
42
|
+
"recipe[service1]"
|
43
|
+
]
|
44
|
+
,
|
45
|
+
"service1": {
|
46
|
+
"option1": "here we go"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
51
|
+
Inside Chef recipes, you can access those values by using the `node` object.
|
52
|
+
For example:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
template "/etc/service1.conf.d/option1.conf" do
|
56
|
+
variables option1: node["option1"]
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
## Bootstrapping
|
61
|
+
|
62
|
+
The bootstrap process for _chef_ involves getting chef-solo installed. The
|
63
|
+
node hostname will also be set based on the hostname informed in the
|
64
|
+
configuration file.
|
65
|
+
|
66
|
+
## See also
|
67
|
+
|
68
|
+
* **chake(1)**
|
69
|
+
* <https://docs.chef.io/>
|
70
|
+
* <https://docs.chef.io/chef_solo.html>
|
data/README.itamae.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
chake-itamae(7) -- configure chake nodes with itamae
|
2
|
+
====================================================
|
3
|
+
|
4
|
+
## Description
|
5
|
+
|
6
|
+
This configuration manager will run **itamae(1)** against your nodes.
|
7
|
+
|
8
|
+
## Configuration
|
9
|
+
|
10
|
+
The _itamae_ configuration manager requires one key called `itamae`, and the
|
11
|
+
value must be a list of strings representing the list of recipes to apply to
|
12
|
+
the node when converging.
|
13
|
+
|
14
|
+
```yaml
|
15
|
+
host1.mycompany.com:
|
16
|
+
itamae:
|
17
|
+
- cookbooks/basic/default.rb
|
18
|
+
- roles/server.rb
|
19
|
+
service1:
|
20
|
+
option1: "here we go"
|
21
|
+
```
|
22
|
+
|
23
|
+
Any extra configuration under `host1.mycompany.com` will be saved to a JSON file
|
24
|
+
and given to the itamae --node-json option in the command line. For example,
|
25
|
+
the above configuration will produce a JSON file that looks like this:
|
26
|
+
|
27
|
+
```json
|
28
|
+
{
|
29
|
+
"itamae": [
|
30
|
+
"cookbooks/basic.rb",
|
31
|
+
"roles/server.rb"
|
32
|
+
]
|
33
|
+
,
|
34
|
+
"service1": {
|
35
|
+
"option1": "here we go"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
```
|
39
|
+
|
40
|
+
Inside itamae recipes, you can access those values by using the `node` object.
|
41
|
+
For example:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
template "/etc/service1.conf.d/option1.conf" do
|
45
|
+
variables option1: node["option1"]
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
## Bootstrapping
|
50
|
+
|
51
|
+
Very little bootstrapping is required for this configuration manager, as itamae
|
52
|
+
requires no setup on the node site since the Ruby code in the recipes is
|
53
|
+
interpreted locally and not on the nodes. During bootstrapping, only the node
|
54
|
+
hostname will be set according to your chake configuration.
|
55
|
+
|
56
|
+
## See also
|
57
|
+
|
58
|
+
* **chake(1)**
|
data/README.md
CHANGED
@@ -1,42 +1,58 @@
|
|
1
|
-
|
1
|
+
chake(1) -- serverless configuration management tool
|
2
|
+
========================================
|
2
3
|
|
3
|
-
##
|
4
|
+
## SYNOPSIS
|
4
5
|
|
5
|
-
chake
|
6
|
+
`chake` init
|
6
7
|
|
7
|
-
|
8
|
+
`chake` [rake arguments]
|
8
9
|
|
9
|
-
|
10
|
-
a chef server. Configuration is managed in a local directory, which should
|
11
|
-
probably be under version control with **git(1)** or anything else.
|
12
|
-
Configuration is usually deployed via rsync over SSH, and applied by invoking
|
13
|
-
**chef-solo(1)** over SSH on each host.
|
10
|
+
## Description
|
14
11
|
|
15
|
-
|
12
|
+
chake is a tool that helps you manage multiple hosts without the need for a
|
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. áéíóú
|
16
16
|
|
17
|
-
|
17
|
+
Configuration is deployed to managed hosts remotely, either by invoking a
|
18
|
+
configuration management tool that will connect to them, or by first uploading
|
19
|
+
the necessary configuration and them remotely running a tool on the hosts.
|
18
20
|
|
19
|
-
##
|
21
|
+
## Supported configuration managers.
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
chake supports the following configuration management tools:
|
24
|
+
|
25
|
+
* **itamae**: configuration is applied by running the itamae command line tool
|
26
|
+
on the management host; no configuration needs to be uploaded to the managed
|
27
|
+
hosts. See chake-itamae(7) for details.
|
28
|
+
* **shell**: the local repository is copied to the host, and the shell commands
|
29
|
+
specified in the node configuration is executed from the directory where that
|
30
|
+
copy is. See chake-shell(7) for details.
|
31
|
+
* **chef**: the local repository is copied to the host, and **chef-solo** is
|
32
|
+
executed remotely on the managed host. See chake-chef(7) for details.
|
33
|
+
|
34
|
+
Beyond applying configuration management recipes on the hosts, chake also
|
35
|
+
provides useful tools to manage multiple hosts, such as listing nodes, running
|
36
|
+
commands against all of them simultaneously, logging in to interactive
|
37
|
+
shells, and others.
|
38
|
+
|
39
|
+
## creating the repository
|
40
|
+
|
41
|
+
$ chake init[:configmanager]
|
31
42
|
|
32
|
-
|
43
|
+
This will create an initial directory structure. Some of the files are specific
|
44
|
+
to your your chosen **configmanager**, which can be one of [SUPPORTED
|
45
|
+
CONFIGURATION MANAGERS]. The following files, though, will be common to any
|
46
|
+
usage of chake:
|
33
47
|
|
34
|
-
* `nodes.yaml`: where you will list the hosts you will be managing, and what
|
35
|
-
|
36
|
-
* `
|
37
|
-
|
38
|
-
* `
|
39
|
-
|
48
|
+
* `nodes.yaml`: where you will list the hosts you will be managing, and what
|
49
|
+
recipes to apply to each of them.
|
50
|
+
* `nodes.d`: a directory with multiple files in the same format as nodes.yaml.
|
51
|
+
All files matching `*.yaml` in it will be added to the list of nodes.
|
52
|
+
* `Rakefile`: Contains just the `require 'chake'` line. You can augment it with
|
53
|
+
other tasks specific to your intrastructure.
|
54
|
+
|
55
|
+
If you omit _configmanager_, `itamae` will be used by default.
|
40
56
|
|
41
57
|
After the repository is created, you can call either `chake` or `rake`, as they
|
42
58
|
are completely equivalent.
|
@@ -48,10 +64,12 @@ following:
|
|
48
64
|
|
49
65
|
```yaml
|
50
66
|
host1.mycompany.com:
|
51
|
-
|
52
|
-
-
|
67
|
+
itamae:
|
68
|
+
- roles/basic.rb
|
53
69
|
```
|
54
70
|
|
71
|
+
The exact contents depends on the chosen configuration management tool.
|
72
|
+
|
55
73
|
You can list your hosts with `rake nodes`:
|
56
74
|
|
57
75
|
```
|
@@ -63,11 +81,11 @@ To add more nodes, just append to `nodes.yaml`:
|
|
63
81
|
|
64
82
|
```yaml
|
65
83
|
host1.mycompany.com:
|
66
|
-
|
67
|
-
-
|
84
|
+
itamae:
|
85
|
+
- roles/basic.rb
|
68
86
|
host2.mycompany.com:
|
69
|
-
|
70
|
-
-
|
87
|
+
itamae:
|
88
|
+
- roles/basic.rb
|
71
89
|
```
|
72
90
|
|
73
91
|
And chake now knows about your new node:
|
@@ -100,55 +118,53 @@ password prompts, you can:
|
|
100
118
|
|
101
119
|
## Checking connectivity and initial host setup
|
102
120
|
|
103
|
-
To check whether hosts are
|
121
|
+
To check whether hosts are correctly configured, you can use the `check` task:
|
104
122
|
|
105
|
-
```
|
123
|
+
```
|
106
124
|
$ rake check
|
107
125
|
```
|
108
126
|
|
109
127
|
That will run the the `sudo true` command on each host. If that pass without
|
110
|
-
you having to passwords,
|
128
|
+
you having to type any passwords, it means that:
|
111
129
|
|
112
130
|
* you have SSH access to each host; and
|
113
131
|
* the user you are connecting as has password-less sudo correctly setup.
|
114
132
|
|
115
|
-
|
116
|
-
$ rake check
|
117
|
-
```
|
118
|
-
|
119
|
-
## Applying cookbooks
|
133
|
+
## Applying configuration
|
120
134
|
|
121
135
|
Note that by default all tasks that apply to all hosts will run in parallel,
|
122
136
|
using rake's support for multitasks. If for some reason you need to prevent
|
123
137
|
that, you can pass `-j1` (or --jobs=1`) in the rake invocation. Note that by
|
124
138
|
default rake will only run N+4 tasks in parallel, where N is the number of
|
125
139
|
cores on the machine you are running it. If you have more than N+4 hosts and
|
126
|
-
want all of them to be handled in parallel, you might want
|
140
|
+
want all of them to be handled in parallel, you might want to pass `-j` (or
|
127
141
|
`--jobs`), without any number, as the last argument; with that rake will have
|
128
142
|
no limit on the number of tasks to perform in parallel.
|
129
143
|
|
130
|
-
|
131
144
|
To apply the configuration to all nodes, run
|
132
145
|
|
133
|
-
```
|
146
|
+
```
|
134
147
|
$ rake converge
|
135
148
|
```
|
136
149
|
|
137
150
|
To apply the configuration to a single node, run
|
138
151
|
|
139
|
-
```
|
152
|
+
```
|
140
153
|
$ rake converge:$NODE
|
141
154
|
```
|
142
155
|
|
143
156
|
To apply a single recipe on all nodes, run
|
144
157
|
|
145
|
-
```
|
158
|
+
```
|
146
159
|
$ rake apply[myrecipe]
|
147
160
|
```
|
148
161
|
|
162
|
+
What `recipe` is depends on the configuration manager.
|
163
|
+
|
164
|
+
|
149
165
|
To apply a single recipe on a specific node, run
|
150
166
|
|
151
|
-
```
|
167
|
+
```
|
152
168
|
$ rake apply:$NODE[myrecipe]
|
153
169
|
```
|
154
170
|
|
@@ -156,12 +172,24 @@ If you don't inform a recipe in the command line, you will be prompted for one.
|
|
156
172
|
|
157
173
|
To run a shell command on all nodes, run
|
158
174
|
|
175
|
+
```
|
176
|
+
$ rake run
|
177
|
+
```
|
178
|
+
The above will prompt you for a command, then execute it on all nodes.
|
179
|
+
|
180
|
+
To pass the command to run in the command line, use the following syntax:
|
181
|
+
|
159
182
|
```
|
160
183
|
$ rake run[command]
|
161
184
|
```
|
162
185
|
|
163
186
|
If the `command` you want to run contains spaces, or other characters that are
|
164
|
-
special do the shell, you have to quote them
|
187
|
+
special do the shell, you have to quote them, for example:
|
188
|
+
|
189
|
+
```
|
190
|
+
$ rake run["cat /etc/hostname"]
|
191
|
+
```
|
192
|
+
|
165
193
|
|
166
194
|
To run a shell command on a specific node, run
|
167
195
|
|
@@ -169,28 +197,29 @@ To run a shell command on a specific node, run
|
|
169
197
|
$ rake run:$NODE[command]
|
170
198
|
```
|
171
199
|
|
172
|
-
|
173
|
-
|
200
|
+
As before, if you run just `rake run:$NODE`, you will be prompted for the
|
201
|
+
command.
|
174
202
|
|
175
|
-
To
|
203
|
+
To list all existing tasks, run:
|
176
204
|
|
177
|
-
```
|
205
|
+
```
|
178
206
|
$ rake -T
|
179
207
|
```
|
180
208
|
|
181
|
-
## Writing
|
209
|
+
## Writing configuration management code
|
182
210
|
|
183
|
-
|
184
|
-
|
185
|
-
|
211
|
+
As chake supports different configuration management tools, the specifics of
|
212
|
+
configuration management code depends on the the tool you choose. See the
|
213
|
+
corresponding documentation.
|
186
214
|
|
187
215
|
## The node bootstrapping process
|
188
216
|
|
189
|
-
|
190
|
-
|
217
|
+
Some of the configuration management tools require some software to be
|
218
|
+
installed on the managed hosts. When that's the case, chake acts on a node for
|
219
|
+
the first time, it has to bootstrap it. The bootstrapping process includes
|
220
|
+
doing the following:
|
191
221
|
|
192
|
-
- installing
|
193
|
-
- disabling the chef client daemon
|
222
|
+
- installing and configuring the needed software
|
194
223
|
- setting up the hostname
|
195
224
|
|
196
225
|
## Node URLs
|
@@ -201,10 +230,10 @@ is the simplest form of specifying your nodes. Here are all the components of
|
|
201
230
|
the node URLs:
|
202
231
|
|
203
232
|
```
|
204
|
-
[
|
233
|
+
[connection://][username@]hostname[:port][/path]
|
205
234
|
```
|
206
235
|
|
207
|
-
* `
|
236
|
+
* `connection`: what to use to connect to the host. `ssh` or `local` (default: `ssh`)
|
208
237
|
* `username`: user name to connect with (default: the username on your local workstation)
|
209
238
|
* `hostname`: the hostname to connect to (default: _none_)
|
210
239
|
* `port`: port number to connect to (default: 22)
|
@@ -228,7 +257,7 @@ converging. To do this, you just need to enhance the corresponding tasks:
|
|
228
257
|
|
229
258
|
Example:
|
230
259
|
|
231
|
-
```
|
260
|
+
```ruby
|
232
261
|
task :bootstrap_common do
|
233
262
|
sh './scripts/pre-bootstrap-checks'
|
234
263
|
end
|
@@ -237,7 +266,8 @@ end
|
|
237
266
|
### Encrypted files
|
238
267
|
|
239
268
|
Any files ending matching `*.gpg` and `*.asc` will be decrypted with GnuPG
|
240
|
-
before being sent to the node
|
269
|
+
before being sent to the node (for the configuration management tools that
|
270
|
+
required files to be sent). You can use them to store passwords and other
|
241
271
|
sensitive information (SSL keys, etc) in the repository together with the rest
|
242
272
|
of the configuration.
|
243
273
|
|
@@ -260,7 +290,7 @@ Some times, you will also want or need to prefix your SSH invocations with some
|
|
260
290
|
prefix command in order to e.g. tunnel it through some central exit node. You
|
261
291
|
can do this by setting `$CHAKE_SSH_PREFIX` on your environment. Example:
|
262
292
|
|
263
|
-
```
|
293
|
+
```bash
|
264
294
|
CHAKE_SSH_PREFIX=tsocks rake converge
|
265
295
|
```
|
266
296
|
|
@@ -269,33 +299,48 @@ The above will make all SSH invocations to all hosts be called as `tsocks ssh
|
|
269
299
|
|
270
300
|
### Converging local host
|
271
301
|
|
272
|
-
If you want to manage your local workstation with chake, you can declare a
|
302
|
+
If you want to manage your local workstation with chake, you can declare a
|
303
|
+
local node using the "local" connection type, like this (in `nodes.yaml`):
|
273
304
|
|
274
305
|
```yaml
|
275
306
|
local://thunderbolt:
|
276
|
-
|
277
|
-
- role
|
307
|
+
itamae:
|
308
|
+
- role/workstation.rb
|
278
309
|
```
|
279
310
|
|
280
311
|
To apply the configuration to the local host, you can use the conventional
|
281
312
|
`rake converge:thunderbolt`, or the special target `rake local`.
|
282
313
|
|
283
314
|
When converging all nodes, `chake` will skip nodes that are declared with the
|
284
|
-
`local://`
|
315
|
+
`local://` connection and whose hostname does not match the hostname in the
|
285
316
|
declaration. For example:
|
286
317
|
|
287
318
|
```yaml
|
288
319
|
local://desktop:
|
289
|
-
|
290
|
-
- role
|
320
|
+
itamae:
|
321
|
+
- role/workstation.rb
|
291
322
|
local://laptop:
|
292
|
-
|
293
|
-
- role
|
323
|
+
itamae:
|
324
|
+
- role/workstation.rb
|
294
325
|
```
|
295
326
|
|
296
327
|
When you run `rake converge` on `desktop`, `laptop` will be skipped, and
|
297
328
|
vice-versa.
|
298
329
|
|
330
|
+
### Accessing node data from your own tasks
|
331
|
+
|
332
|
+
It's often useful to be able to run arbitrary commands against the data you
|
333
|
+
have about nodes. You can use the `Chake.nodes` for that. For example, if you
|
334
|
+
want to geolocate each of yours hosts:
|
335
|
+
|
336
|
+
```ruby
|
337
|
+
task :geolocate do
|
338
|
+
Chake.nodes.each do |node|
|
339
|
+
puts "#{node.hostname}: %s" % `geoiplookup #{node.hostname}`.strip
|
340
|
+
end
|
341
|
+
end
|
342
|
+
```
|
343
|
+
|
299
344
|
## Environment variables
|
300
345
|
|
301
346
|
* `$CHAKE_SSH_CONFIG`:
|
@@ -316,13 +361,7 @@ vice-versa.
|
|
316
361
|
|
317
362
|
## See also
|
318
363
|
|
319
|
-
* **rake(1)
|
320
|
-
*
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
1. Fork it ( http://github.com/terceiro/chake/fork )
|
325
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
326
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
327
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
328
|
-
5. Create new Pull Request
|
364
|
+
* **rake(1)**
|
365
|
+
* **chake-itamae(7)**, https://itamae.kitchen/
|
366
|
+
* **chake-shell(7)**
|
367
|
+
* **chake-chef(7)**, **chef-solo(1)**, https://docs.chef.io/
|