kitchen-nodes 0.5.0 → 0.6.0
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/.gitignore +1 -0
- data/Gemfile +1 -0
- data/README.md +14 -2
- data/lib/kitchen/provisioner/nodes.rb +19 -1
- data/lib/kitchen/provisioner/nodes_version.rb +1 -1
- data/lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb +33 -0
- data/spec/unit/nodes_spec.rb +7 -1
- metadata +3 -11
- data/test/integration/nodes/node1-ubuntu-1204.json +0 -22
- data/test/integration/nodes/node1-windows-2012R2.json +0 -21
- data/test/integration/nodes/node2-ubuntu-1204.json +0 -22
- data/test/integration/nodes/node2-windows-2012R2.json +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 740fc4fc0bb5e9e69004285216c232ce23e1b9be
|
4
|
+
data.tar.gz: b5d9dd976ce3e579cc431e1a2a16d17a5e1b9a26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 124a5b80d69634b68e88de94711325d16278a3f100a61a825db4321c499a0b3a9dad5d58e77622d851eca8e7761053331de12e19f478237a75cff60b9e049f67
|
7
|
+
data.tar.gz: b4d65e7ad42faf4b2d0f942bd2d40793cc573fb4ebcfa4d81cfab4f60fd53b69dce1044b988670f76ecb26209e15fc02d3a8a038bbeb4b9706b452cf8fb3d4ee
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -11,7 +11,13 @@ The nodes provisioner extends the `chef-zero` provisioner along with all of its
|
|
11
11
|
"id": "server-community-ubuntu-1204",
|
12
12
|
"automatic": {
|
13
13
|
"ipaddress": "172.17.0.8",
|
14
|
-
"platform": "ubuntu"
|
14
|
+
"platform": "ubuntu",
|
15
|
+
"recipes": [
|
16
|
+
"apt::default",
|
17
|
+
"couchbase-tests::ipaddress",
|
18
|
+
"couchbase::server",
|
19
|
+
"export-node"
|
20
|
+
]
|
15
21
|
},
|
16
22
|
"normal": {
|
17
23
|
"attr1": "val1"
|
@@ -28,7 +34,13 @@ The nodes provisioner extends the `chef-zero` provisioner along with all of its
|
|
28
34
|
"id": "second-node-ubuntu-1204",
|
29
35
|
"automatic": {
|
30
36
|
"ipaddress": "172.17.0.9",
|
31
|
-
"platform": "ubuntu"
|
37
|
+
"platform": "ubuntu",
|
38
|
+
"recipes": [
|
39
|
+
"apt::default",
|
40
|
+
"couchbase-tests::ipaddress",
|
41
|
+
"couchbase::server",
|
42
|
+
"export-node"
|
43
|
+
]
|
32
44
|
},
|
33
45
|
"run_list": [
|
34
46
|
"recipe[apt]",
|
@@ -19,7 +19,9 @@
|
|
19
19
|
require 'kitchen'
|
20
20
|
require 'kitchen/provisioner/chef_zero'
|
21
21
|
require 'kitchen/provisioner/finder'
|
22
|
+
require 'kitchen/provisioner/run_list_expansion_from_kitchen'
|
22
23
|
require 'net/ping'
|
24
|
+
require 'chef/run_list'
|
23
25
|
|
24
26
|
module Kitchen
|
25
27
|
module Provisioner
|
@@ -69,6 +71,19 @@ module Kitchen
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
74
|
+
def recipes
|
75
|
+
rl = config[:run_list].map do |item|
|
76
|
+
::Chef::RunList::RunListItem.new item
|
77
|
+
end
|
78
|
+
rle = RunListExpansionFromKitchen.new(
|
79
|
+
chef_environment,
|
80
|
+
rl,
|
81
|
+
config[:roles_path]
|
82
|
+
)
|
83
|
+
rle.expand
|
84
|
+
rle.recipes
|
85
|
+
end
|
86
|
+
|
72
87
|
def chef_environment
|
73
88
|
env = '_default'
|
74
89
|
if config[:client_rb] && config[:client_rb][:environment]
|
@@ -77,6 +92,7 @@ module Kitchen
|
|
77
92
|
env
|
78
93
|
end
|
79
94
|
|
95
|
+
# rubocop:disable Metrics/AbcSize
|
80
96
|
def node_template
|
81
97
|
{
|
82
98
|
id: instance.name,
|
@@ -84,12 +100,14 @@ module Kitchen
|
|
84
100
|
automatic: {
|
85
101
|
ipaddress: ipaddress,
|
86
102
|
platform: instance.platform.name.split('-')[0].downcase,
|
87
|
-
fqdn: fqdn
|
103
|
+
fqdn: fqdn,
|
104
|
+
recipes: recipes
|
88
105
|
},
|
89
106
|
normal: config[:attributes],
|
90
107
|
run_list: config[:run_list]
|
91
108
|
}
|
92
109
|
end
|
110
|
+
# rubocop:enable Metrics/AbcSize
|
93
111
|
|
94
112
|
def node_dir
|
95
113
|
File.join(config[:test_base_path], 'nodes')
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2015, Matt Wrock
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require 'chef/role'
|
20
|
+
|
21
|
+
module Kitchen
|
22
|
+
module Provisioner
|
23
|
+
# fetches roles from kitchen roles directory
|
24
|
+
class RunListExpansionFromKitchen < ::Chef::RunList::RunListExpansion
|
25
|
+
def fetch_role(name, included_by, role_dir)
|
26
|
+
role_file = File.join(role_dir, "#{name}.json")
|
27
|
+
Chef::Role.json_create(JSON.parse(File.read(role_file)))
|
28
|
+
rescue Chef::Exceptions::RoleNotFound
|
29
|
+
role_not_found(name, included_by)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/unit/nodes_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Kitchen::Provisioner::Nodes do
|
|
12
12
|
{
|
13
13
|
test_base_path: '/b',
|
14
14
|
kitchen_root: '/r',
|
15
|
-
run_list: 'cookbook
|
15
|
+
run_list: ['recipe[cookbook::default]'],
|
16
16
|
attributes: { att_key: 'att_val' },
|
17
17
|
client_rb: { environment: 'my_env' }
|
18
18
|
}
|
@@ -75,6 +75,12 @@ describe Kitchen::Provisioner::Nodes do
|
|
75
75
|
expect(node[:run_list]).to eq config[:run_list]
|
76
76
|
end
|
77
77
|
|
78
|
+
it 'expands the runlist' do
|
79
|
+
subject.create_node
|
80
|
+
|
81
|
+
expect(node[:automatic][:recipes]).to eq ['cookbook::default']
|
82
|
+
end
|
83
|
+
|
78
84
|
it 'sets the normal attributes' do
|
79
85
|
subject.create_node
|
80
86
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-nodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wrock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ping
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/kitchen/provisioner/finder/winrm.rb
|
145
145
|
- lib/kitchen/provisioner/nodes.rb
|
146
146
|
- lib/kitchen/provisioner/nodes_version.rb
|
147
|
+
- lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb
|
147
148
|
- spec/unit/nodes_spec.rb
|
148
149
|
- spec/unit/stubs/ifconfig.txt
|
149
150
|
- spec/unit/stubs/ip.txt
|
@@ -154,10 +155,6 @@ files:
|
|
154
155
|
- test/integration/node1/serverspec/default_spec.rb
|
155
156
|
- test/integration/node2/serverspec/Gemfile
|
156
157
|
- test/integration/node2/serverspec/default_spec.rb
|
157
|
-
- test/integration/nodes/node1-ubuntu-1204.json
|
158
|
-
- test/integration/nodes/node1-windows-2012R2.json
|
159
|
-
- test/integration/nodes/node2-ubuntu-1204.json
|
160
|
-
- test/integration/nodes/node2-windows-2012R2.json
|
161
158
|
homepage: ''
|
162
159
|
licenses:
|
163
160
|
- Apache 2.0
|
@@ -193,8 +190,3 @@ test_files:
|
|
193
190
|
- test/integration/node1/serverspec/default_spec.rb
|
194
191
|
- test/integration/node2/serverspec/Gemfile
|
195
192
|
- test/integration/node2/serverspec/default_spec.rb
|
196
|
-
- test/integration/nodes/node1-ubuntu-1204.json
|
197
|
-
- test/integration/nodes/node1-windows-2012R2.json
|
198
|
-
- test/integration/nodes/node2-ubuntu-1204.json
|
199
|
-
- test/integration/nodes/node2-windows-2012R2.json
|
200
|
-
has_rdoc:
|
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "node1-ubuntu-1204",
|
3
|
-
"chef_environment": "_default",
|
4
|
-
"automatic": {
|
5
|
-
"ipaddress": "192.168.1.147",
|
6
|
-
"platform": "ubuntu",
|
7
|
-
"fqdn": "node1-ubuntu-1204"
|
8
|
-
},
|
9
|
-
"normal": {
|
10
|
-
"consul": {
|
11
|
-
"config": {
|
12
|
-
"bootstrap_expect": 2,
|
13
|
-
"server": true
|
14
|
-
}
|
15
|
-
}
|
16
|
-
},
|
17
|
-
"run_list": [
|
18
|
-
"recipe[apt]",
|
19
|
-
"recipe[hurry-up-and-test::set_non_nat_vbox_ip]",
|
20
|
-
"recipe[node-tests::node1]"
|
21
|
-
]
|
22
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "node1-windows-2012R2",
|
3
|
-
"chef_environment": "_default",
|
4
|
-
"automatic": {
|
5
|
-
"ipaddress": "192.168.1.149",
|
6
|
-
"platform": "windows",
|
7
|
-
"fqdn": "WIN-HKCPKCREPB8"
|
8
|
-
},
|
9
|
-
"normal": {
|
10
|
-
"consul": {
|
11
|
-
"config": {
|
12
|
-
"bootstrap_expect": 2,
|
13
|
-
"server": true
|
14
|
-
}
|
15
|
-
}
|
16
|
-
},
|
17
|
-
"run_list": [
|
18
|
-
"recipe[hurry-up-and-test::set_non_nat_vbox_ip]",
|
19
|
-
"recipe[node-tests::node1]"
|
20
|
-
]
|
21
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "node2-ubuntu-1204",
|
3
|
-
"chef_environment": "_default",
|
4
|
-
"automatic": {
|
5
|
-
"ipaddress": "192.168.1.148",
|
6
|
-
"platform": "ubuntu",
|
7
|
-
"fqdn": "node2-ubuntu-1204"
|
8
|
-
},
|
9
|
-
"normal": {
|
10
|
-
"consul": {
|
11
|
-
"config": {
|
12
|
-
"bootstrap_expect": 2,
|
13
|
-
"server": true
|
14
|
-
}
|
15
|
-
}
|
16
|
-
},
|
17
|
-
"run_list": [
|
18
|
-
"recipe[apt]",
|
19
|
-
"recipe[hurry-up-and-test::set_non_nat_vbox_ip]",
|
20
|
-
"recipe[node-tests::node2]"
|
21
|
-
]
|
22
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"id": "node2-windows-2012R2",
|
3
|
-
"chef_environment": "_default",
|
4
|
-
"automatic": {
|
5
|
-
"ipaddress": "192.168.1.150",
|
6
|
-
"platform": "windows",
|
7
|
-
"fqdn": "WIN-70EEPS83GN7"
|
8
|
-
},
|
9
|
-
"normal": {
|
10
|
-
"consul": {
|
11
|
-
"config": {
|
12
|
-
"bootstrap_expect": 2,
|
13
|
-
"server": true
|
14
|
-
}
|
15
|
-
}
|
16
|
-
},
|
17
|
-
"run_list": [
|
18
|
-
"recipe[hurry-up-and-test::set_non_nat_vbox_ip]",
|
19
|
-
"recipe[node-tests::node2]"
|
20
|
-
]
|
21
|
-
}
|