sous-chef 0.0.4 → 0.0.5
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.
- data/Gemfile.lock +1 -1
- data/README.md +41 -24
- data/lib/sous-chef/environment.rb +20 -0
- data/lib/sous-chef/manager.rb +7 -12
- data/lib/sous-chef/node.rb +2 -2
- data/lib/sous-chef/tasks.rb +36 -15
- data/lib/sous-chef.rb +1 -0
- data/lib/templates/nodes.example.yml +23 -9
- data/sous-chef.gemspec +3 -2
- data/spec/fixtures/some_nodes.yml +17 -10
- data/spec/sous-chef/environment_spec.rb +17 -0
- data/spec/sous-chef/manager_spec.rb +2 -8
- data/spec/sous-chef/parser_spec.rb +1 -1
- metadata +6 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Sous Chef
|
2
2
|
|
3
|
-
Note: This gem is a work in progress.
|
4
|
-
|
5
3
|
Manage [knife-solo](http://matschaffer.github.com/knife-solo/) nodes.
|
6
4
|
|
7
5
|
## Install
|
@@ -12,7 +10,8 @@ Add the following to your `Rakefile`:
|
|
12
10
|
require 'sous-chef'
|
13
11
|
```
|
14
12
|
|
15
|
-
You may run `rake sous_chef` to generate sample `nodes.yml` to
|
13
|
+
You may run `rake sous_chef:init` to generate sample `nodes.yml` to
|
14
|
+
`nodes/nodes.yml`
|
16
15
|
|
17
16
|
## Configure
|
18
17
|
|
@@ -22,31 +21,49 @@ configuration is used for sshconfig as well as nodename. Example `nodes.yml`:
|
|
22
21
|
```yaml
|
23
22
|
# Format:
|
24
23
|
#
|
25
|
-
# <
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
24
|
+
# <environment>:
|
25
|
+
# <node name>:
|
26
|
+
# node_config: <knife-solo node config e.g. nodes/someNode.json>
|
27
|
+
# ssh_config:
|
28
|
+
# <ssh config options>
|
29
|
+
# e.g.
|
30
|
+
# Host: <host alias. defaults to node name>
|
31
|
+
# HostName: 12.34.56.789
|
32
|
+
# Port: 1234
|
33
|
+
# IdentityFile: ~/.ssh/other_id_rsa
|
34
|
+
|
35
|
+
production:
|
36
|
+
SuperAwesomeNode:
|
37
|
+
node_config: nodes/some_node.json
|
38
|
+
ssh_config:
|
39
|
+
HostName: 12.34.56.789
|
40
|
+
Port 1234
|
41
|
+
IdentityFile: ~/.ssh/other_id_rsa
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
CoolWorld:
|
44
|
+
node_config: nodes/some_node.json
|
45
|
+
ssh_config:
|
46
|
+
HostName: localhost
|
47
|
+
|
48
|
+
vagrant:
|
49
|
+
default:
|
50
|
+
node_config: nodes/buildAgent.json
|
51
|
+
ssh_config:
|
52
|
+
HostName: 127.0.0.1
|
53
|
+
User: vagrant
|
54
|
+
Port: 2222
|
55
|
+
UserKnownHostsFile: /dev/null
|
56
|
+
StrictHostKeyChecking: "no"
|
57
|
+
PasswordAuthentication: "no"
|
58
|
+
IdentityFile: "~/.vagrant.d/insecure_private_key"
|
59
|
+
IdentitiesOnly: "yes"
|
60
|
+
ForwardAgent: "yes"
|
47
61
|
```
|
48
62
|
|
49
63
|
## Usage
|
50
64
|
|
51
65
|
`rake -T` for a full list of tasks provided:
|
52
66
|
|
67
|
+
`rake <environment>:all:<knife solo task>` will run on all nodes for a given
|
68
|
+
environment.
|
69
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SousChef
|
2
|
+
class Environment
|
3
|
+
attr_reader :nodes, :name
|
4
|
+
|
5
|
+
def initialize(name, nodes)
|
6
|
+
@nodes = {}
|
7
|
+
@name = name
|
8
|
+
initialize_nodes(nodes)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def initialize_nodes(nodes)
|
14
|
+
nodes.each do |name, settings|
|
15
|
+
@nodes[name] = Node.new(name, settings)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/lib/sous-chef/manager.rb
CHANGED
@@ -1,25 +1,20 @@
|
|
1
1
|
module SousChef
|
2
2
|
class Manager
|
3
|
-
|
4
|
-
attr_reader :parser
|
3
|
+
attr_reader :envs, :parser
|
5
4
|
|
6
5
|
def initialize(config_file)
|
7
6
|
@parser = Parser.new(config_file)
|
8
|
-
@
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def all
|
13
|
-
@nodes.keys
|
7
|
+
@envs = {}
|
8
|
+
initialize_environments
|
14
9
|
end
|
15
10
|
|
16
11
|
private
|
17
12
|
|
18
|
-
def
|
19
|
-
@parser.parse.each do |
|
20
|
-
@
|
13
|
+
def initialize_environments
|
14
|
+
@parser.parse.each do |name, nodes|
|
15
|
+
@envs[name] = Environment.new(name, nodes)
|
21
16
|
end
|
22
17
|
end
|
23
|
-
|
24
18
|
end
|
25
19
|
end
|
20
|
+
|
data/lib/sous-chef/node.rb
CHANGED
data/lib/sous-chef/tasks.rb
CHANGED
@@ -10,27 +10,48 @@ def run_knife(command, node)
|
|
10
10
|
run "knife solo #{command} -F #{node.ssh_config_path} #{node.hostname} -N #{node.name} #{node.config}"
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def build_task_list(environment_name, names, task)
|
14
|
+
names.map { |name| "#{environment_name}:#{name}:#{task}" }
|
15
|
+
end
|
16
|
+
|
17
|
+
SousChef::Manager.new(SousChef::CONFIG_FILE).envs.each do |environment_name, env|
|
18
|
+
namespace environment_name do
|
19
|
+
namespace :all do
|
20
|
+
desc "Run knife solo prepare for all #{environment_name} nodes"
|
21
|
+
multitask :prepare => build_task_list(environment_name, env.nodes.keys, "prepare")
|
22
|
+
|
23
|
+
desc "Run knife solo cook for all #{environment_name} nodes"
|
24
|
+
multitask :cook => build_task_list(environment_name, env.nodes.keys, "cook")
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
run_knife 'cook', node
|
26
|
+
desc "Run knife solo bootstrap for all #{environment_name} nodes"
|
27
|
+
multitask :bootstrap => build_task_list(environment_name, env.nodes.keys, "bootstrap")
|
23
28
|
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
env.nodes.each do |node_name, node|
|
31
|
+
namespace node_name do
|
32
|
+
desc "Run knife solo prepare for #{node_name}"
|
33
|
+
task :prepare do
|
34
|
+
run_knife 'prepare', node
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Run knife solo cook for #{node_name}"
|
38
|
+
task :cook do
|
39
|
+
run_knife 'cook', node
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Run knife solo bootstrap for #{node_name}"
|
43
|
+
task :bootstrap do
|
44
|
+
run_knife 'bootstrap', node
|
45
|
+
end
|
46
|
+
end
|
28
47
|
end
|
29
48
|
end
|
30
49
|
end
|
31
50
|
|
32
|
-
|
33
|
-
|
34
|
-
|
51
|
+
namespace :sous_chef do
|
52
|
+
desc "Generate nodes.yml example config"
|
53
|
+
task :init do
|
54
|
+
SousChef.create_config
|
55
|
+
end
|
35
56
|
end
|
36
57
|
|
data/lib/sous-chef.rb
CHANGED
@@ -1,13 +1,27 @@
|
|
1
1
|
# Format:
|
2
2
|
#
|
3
|
-
# <
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
3
|
+
# <environment>:
|
4
|
+
# <node name>:
|
5
|
+
# node_config: <knife-solo node config e.g. nodes/someNode.json>
|
6
|
+
# ssh_config:
|
7
|
+
# <ssh config options>
|
8
|
+
# e.g.
|
9
|
+
# Host: <host alias. defaults to node name>
|
10
|
+
# HostName: 12.34.56.789
|
11
|
+
# Port: 1234
|
12
|
+
# IdentityFile: ~/.ssh/other_id_rsa
|
12
13
|
#
|
14
|
+
# vagrant:
|
15
|
+
# default:
|
16
|
+
# node_config: nodes/buildAgent.json
|
17
|
+
# ssh_config:
|
18
|
+
# HostName: 127.0.0.1
|
19
|
+
# User: vagrant
|
20
|
+
# Port: 2222
|
21
|
+
# UserKnownHostsFile: /dev/null
|
22
|
+
# StrictHostKeyChecking: "no"
|
23
|
+
# PasswordAuthentication: "no"
|
24
|
+
# IdentityFile: "~/.vagrant.d/insecure_private_key"
|
25
|
+
# IdentitiesOnly: "yes"
|
26
|
+
# ForwardAgent: "yes"
|
13
27
|
|
data/sous-chef.gemspec
CHANGED
@@ -6,9 +6,10 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.email = "shaun@substantail.com"
|
7
7
|
|
8
8
|
s.name = 'sous-chef'
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.5"
|
10
10
|
s.description = %q{Manage knife-solo nodes}
|
11
|
-
s.summary = %q{Manage knife-solo nodes
|
11
|
+
s.summary = %q{Manage knife-solo nodes by environment. Run knife solo
|
12
|
+
commands on one or multiple nodes.}
|
12
13
|
s.homepage = %q{http://github.com/substantial/sous-chef}
|
13
14
|
s.license = "MIT"
|
14
15
|
|
@@ -1,12 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
IdentityFile: ~/.ssh/other_id_rsa
|
1
|
+
production:
|
2
|
+
OtherAwesome:
|
3
|
+
node_config: some/path/to/node/config
|
4
|
+
ssh_config:
|
5
|
+
HostName: localhost
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
CoolWorld:
|
8
|
+
node_config: some/path/to/node/config
|
9
|
+
ssh_config:
|
10
|
+
HostName: Some Ip
|
11
|
+
|
12
|
+
staging:
|
13
|
+
AwesomeDBServer:
|
14
|
+
node_config: some/path/to/node/config
|
15
|
+
ssh_config:
|
16
|
+
HostName: 12.34.56.789
|
17
|
+
Port: 1234
|
18
|
+
IdentityFile: ~/.ssh/other_id_rsa
|
12
19
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SousChef::Environment do
|
4
|
+
let(:nodes) { {} }
|
5
|
+
let(:environment) { SousChef::Environment.new('some environment', nodes) }
|
6
|
+
|
7
|
+
describe "#initialize" do
|
8
|
+
it "sets the name" do
|
9
|
+
environment.name.should == 'some environment'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "has nodes" do
|
13
|
+
environment.nodes.should be_a Hash
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -8,14 +8,8 @@ describe SousChef::Manager do
|
|
8
8
|
manager.parser.should be_a SousChef::Parser
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
manager.
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#all" do
|
17
|
-
it "returns node names" do
|
18
|
-
manager.all.should =~ %w[SuperAwesomeNode OtherAwesome]
|
11
|
+
it "has environments" do
|
12
|
+
manager.envs.should be_a Hash
|
19
13
|
end
|
20
14
|
end
|
21
15
|
end
|
@@ -13,7 +13,7 @@ describe SousChef::Parser do
|
|
13
13
|
subject { SousChef::Parser.new(File.join(SPEC_ROOT, "fixtures", "some_nodes.yml")).parse }
|
14
14
|
|
15
15
|
it "parses yaml" do
|
16
|
-
subject.keys.should =~ %w[
|
16
|
+
subject.keys.should =~ %w[production staging]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sous-chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- README.md
|
104
104
|
- Rakefile
|
105
105
|
- lib/sous-chef.rb
|
106
|
+
- lib/sous-chef/environment.rb
|
106
107
|
- lib/sous-chef/manager.rb
|
107
108
|
- lib/sous-chef/node.rb
|
108
109
|
- lib/sous-chef/parser.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- sous-chef.gemspec
|
113
114
|
- spec/fixtures/single_node.yml
|
114
115
|
- spec/fixtures/some_nodes.yml
|
116
|
+
- spec/sous-chef/environment_spec.rb
|
115
117
|
- spec/sous-chef/manager_spec.rb
|
116
118
|
- spec/sous-chef/node_spec.rb
|
117
119
|
- spec/sous-chef/parser_spec.rb
|
@@ -140,10 +142,12 @@ rubyforge_project: sous-chef
|
|
140
142
|
rubygems_version: 1.8.24
|
141
143
|
signing_key:
|
142
144
|
specification_version: 3
|
143
|
-
summary: Manage knife-solo nodes
|
145
|
+
summary: Manage knife-solo nodes by environment. Run knife solo commands on one or
|
146
|
+
multiple nodes.
|
144
147
|
test_files:
|
145
148
|
- spec/fixtures/single_node.yml
|
146
149
|
- spec/fixtures/some_nodes.yml
|
150
|
+
- spec/sous-chef/environment_spec.rb
|
147
151
|
- spec/sous-chef/manager_spec.rb
|
148
152
|
- spec/sous-chef/node_spec.rb
|
149
153
|
- spec/sous-chef/parser_spec.rb
|