kitchen-nodes-scalp42 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +3 -0
- data/.gitignore +20 -0
- data/.kitchen.travis.yml +37 -0
- data/.kitchen.yml +48 -0
- data/.rspec +1 -0
- data/.rubocop.yml +9 -0
- data/.travis.yml +22 -0
- data/Berksfile +7 -0
- data/CHANGELOG.md +124 -0
- data/Gemfile +11 -0
- data/LICENSE +15 -0
- data/README.md +154 -0
- data/Rakefile +24 -0
- data/kitchen-nodes.gemspec +31 -0
- data/lib/kitchen/provisioner/finder/ssh.rb +107 -0
- data/lib/kitchen/provisioner/finder/winrm.rb +49 -0
- data/lib/kitchen/provisioner/finder.rb +25 -0
- data/lib/kitchen/provisioner/nodes.rb +163 -0
- data/lib/kitchen/provisioner/nodes_version.rb +24 -0
- data/lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb +38 -0
- data/spec/unit/nodes_spec.rb +279 -0
- data/spec/unit/stubs/ifconfig.txt +36 -0
- data/spec/unit/stubs/ip.txt +15 -0
- data/test/fixtures/roles/test_json_role.json +10 -0
- data/test/fixtures/roles/test_ruby_role.rb +2 -0
- data/test/integration/cookbooks/node-tests/libraries/helper.rb +18 -0
- data/test/integration/cookbooks/node-tests/metadata.rb +4 -0
- data/test/integration/cookbooks/node-tests/recipes/node1.rb +0 -0
- data/test/integration/cookbooks/node-tests/recipes/node2.rb +10 -0
- data/test/integration/node1/serverspec/default_spec.rb +0 -0
- data/test/integration/node2/serverspec/Gemfile +3 -0
- data/test/integration/node2/serverspec/default_spec.rb +69 -0
- metadata +220 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4de2ca05533fe65f1e585c8baf9adf29d88c9dff
|
4
|
+
data.tar.gz: f3aca33735d3cab1fe7e002cd43103b789875b4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8a335d03524d3aaf8118ec046a4d1fe09f0e0f5f89597a7d95b09c43e67f3587fdef17eacdec1fdc5d03822550259768f4a17c425c180af904f2e5cec7a22b9
|
7
|
+
data.tar.gz: a4e8981af9c4de26c0da371054dd40574aa7fa4039b06568c6e486280fe0fd5fee4023d6cb24602874bd48afd4493a919b2d816a300151202607f933d81ee9f0
|
data/.gitattributes
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.kitchen/
|
6
|
+
.yardoc
|
7
|
+
Berksfile.lock
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
test/integration/nodes
|
data/.kitchen.travis.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
driver:
|
3
|
+
name: docker
|
4
|
+
username: vagrant
|
5
|
+
provision_command:
|
6
|
+
- usermod -p $(echo vagrant | openssl passwd -1 -stdin) vagrant
|
7
|
+
- locale-gen en_US.UTF-8
|
8
|
+
- dpkg-reconfigure locales
|
9
|
+
|
10
|
+
provisioner:
|
11
|
+
name: nodes
|
12
|
+
roles_path: test/fixtures/roles
|
13
|
+
require_chef_omnibus: latest
|
14
|
+
|
15
|
+
platforms:
|
16
|
+
- name: ubuntu-14.04
|
17
|
+
|
18
|
+
suites:
|
19
|
+
- name: node1
|
20
|
+
run_list:
|
21
|
+
- role[test_json_role]
|
22
|
+
- role[test_ruby_role]
|
23
|
+
- recipe[node-tests::node1]
|
24
|
+
attributes:
|
25
|
+
consul:
|
26
|
+
config:
|
27
|
+
bootstrap_expect: 2
|
28
|
+
server: true
|
29
|
+
|
30
|
+
- name: node2
|
31
|
+
run_list:
|
32
|
+
- recipe[node-tests::node2]
|
33
|
+
attributes:
|
34
|
+
consul:
|
35
|
+
config:
|
36
|
+
bootstrap_expect: 2
|
37
|
+
server: true
|
data/.kitchen.yml
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
driver:
|
3
|
+
name: vagrant
|
4
|
+
network:
|
5
|
+
- ["private_network", { type: "dhcp" }]
|
6
|
+
|
7
|
+
provisioner:
|
8
|
+
name: nodes
|
9
|
+
roles_path: test/fixtures/roles
|
10
|
+
|
11
|
+
platforms:
|
12
|
+
- name: ubuntu-12.04
|
13
|
+
run_list:
|
14
|
+
- recipe[apt]
|
15
|
+
driver_config:
|
16
|
+
box: hashicorp/precise64
|
17
|
+
|
18
|
+
- name: windows-2016
|
19
|
+
driver_config:
|
20
|
+
gui: true
|
21
|
+
box: mwrock/Windows2016
|
22
|
+
|
23
|
+
- name: windows-2008R2
|
24
|
+
driver_config:
|
25
|
+
gui: true
|
26
|
+
box: opentable/win-2008r2-datacenter-amd64-nocm
|
27
|
+
|
28
|
+
suites:
|
29
|
+
- name: node1
|
30
|
+
run_list:
|
31
|
+
- role[test_json_role]
|
32
|
+
- role[test_ruby_role]
|
33
|
+
- recipe[node-tests::node1]
|
34
|
+
attributes:
|
35
|
+
consul:
|
36
|
+
config:
|
37
|
+
bootstrap_expect: 2
|
38
|
+
server: true
|
39
|
+
|
40
|
+
- name: node2
|
41
|
+
run_list:
|
42
|
+
- recipe[hurry-up-and-test::set_non_nat_vbox_ip]
|
43
|
+
- recipe[node-tests::node2]
|
44
|
+
attributes:
|
45
|
+
consul:
|
46
|
+
config:
|
47
|
+
bootstrap_expect: 2
|
48
|
+
server: true
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation
|
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
matrix:
|
4
|
+
include:
|
5
|
+
- rvm: 2.3.1
|
6
|
+
- rvm: ruby-head
|
7
|
+
- rvm: 2.3.1
|
8
|
+
services: docker
|
9
|
+
sudo: required
|
10
|
+
before_script:
|
11
|
+
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
|
12
|
+
script:
|
13
|
+
- bundle exec kitchen verify
|
14
|
+
after_failure:
|
15
|
+
- cat .kitchen/logs/kitchen.log
|
16
|
+
env:
|
17
|
+
- UBUNTU=14.04
|
18
|
+
- KITCHEN_YAML=.kitchen.travis.yml
|
19
|
+
|
20
|
+
branches:
|
21
|
+
only:
|
22
|
+
- master
|
data/Berksfile
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [0.9.1](https://github.com/mwrock/kitchen-nodes/tree/0.9.1) (2017-03-19)
|
4
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.9.0...0.9.1)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Failed to complete \#converge action: \[undefined method `\[\]' for \#\<WinRM::Output:0x4adaab8\>\] [\#32](https://github.com/mwrock/kitchen-nodes/issues/32)
|
9
|
+
|
10
|
+
**Merged pull requests:**
|
11
|
+
|
12
|
+
- Fix winrm [\#33](https://github.com/mwrock/kitchen-nodes/pull/33) ([mwrock](https://github.com/mwrock))
|
13
|
+
|
14
|
+
## [v0.9.0](https://github.com/mwrock/kitchen-nodes/tree/v0.9.0) (2017-01-13)
|
15
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.8.0...v0.9.0)
|
16
|
+
|
17
|
+
**Closed issues:**
|
18
|
+
|
19
|
+
- Trouble searching the node [\#23](https://github.com/mwrock/kitchen-nodes/issues/23)
|
20
|
+
- Working Example: Nginx Balancer + 2 App Nodes [\#22](https://github.com/mwrock/kitchen-nodes/issues/22)
|
21
|
+
|
22
|
+
**Merged pull requests:**
|
23
|
+
|
24
|
+
- Add support for loading roles from .rb and .json [\#31](https://github.com/mwrock/kitchen-nodes/pull/31) ([dullyouth](https://github.com/dullyouth))
|
25
|
+
|
26
|
+
## [v0.8.0](https://github.com/mwrock/kitchen-nodes/tree/v0.8.0) (2016-09-24)
|
27
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.7.0...v0.8.0)
|
28
|
+
|
29
|
+
**Closed issues:**
|
30
|
+
|
31
|
+
- Searching fqdn and ip on windows breaks [\#28](https://github.com/mwrock/kitchen-nodes/issues/28)
|
32
|
+
- Nodes returned from search are missing attributes from ohai? [\#24](https://github.com/mwrock/kitchen-nodes/issues/24)
|
33
|
+
- policyfile support [\#14](https://github.com/mwrock/kitchen-nodes/issues/14)
|
34
|
+
|
35
|
+
**Merged pull requests:**
|
36
|
+
|
37
|
+
- run kitchen tests in travis/docker [\#27](https://github.com/mwrock/kitchen-nodes/pull/27) ([mwrock](https://github.com/mwrock))
|
38
|
+
- update rubies in travis [\#26](https://github.com/mwrock/kitchen-nodes/pull/26) ([mwrock](https://github.com/mwrock))
|
39
|
+
- Put node object to the "nodes\_path" if defined [\#25](https://github.com/mwrock/kitchen-nodes/pull/25) ([legal90](https://github.com/legal90))
|
40
|
+
|
41
|
+
## [v0.7.0](https://github.com/mwrock/kitchen-nodes/tree/v0.7.0) (2016-03-08)
|
42
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.6.6...v0.7.0)
|
43
|
+
|
44
|
+
**Implemented enhancements:**
|
45
|
+
|
46
|
+
- Added support for windows 2008R2 [\#18](https://github.com/mwrock/kitchen-nodes/pull/18) ([johnsmyth](https://github.com/johnsmyth))
|
47
|
+
|
48
|
+
**Fixed bugs:**
|
49
|
+
|
50
|
+
- Fix device filtering breaking for IPv6 interfaces [\#15](https://github.com/mwrock/kitchen-nodes/pull/15) ([vervas](https://github.com/vervas))
|
51
|
+
|
52
|
+
## [v0.6.6](https://github.com/mwrock/kitchen-nodes/tree/v0.6.6) (2016-02-12)
|
53
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.6.5...v0.6.6)
|
54
|
+
|
55
|
+
**Fixed bugs:**
|
56
|
+
|
57
|
+
- kitchen-nodes fails serverspec test on 2012 node due to unpopulated IP address [\#11](https://github.com/mwrock/kitchen-nodes/issues/11)
|
58
|
+
- Shave extra newline off fqdn [\#13](https://github.com/mwrock/kitchen-nodes/pull/13) ([watkinsv-hp](https://github.com/watkinsv-hp))
|
59
|
+
|
60
|
+
## [v0.6.5](https://github.com/mwrock/kitchen-nodes/tree/v0.6.5) (2016-02-11)
|
61
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.6.4...v0.6.5)
|
62
|
+
|
63
|
+
**Fixed bugs:**
|
64
|
+
|
65
|
+
- kitchen-nodes provisioner needs kitchen-sync sftp finder [\#10](https://github.com/mwrock/kitchen-nodes/issues/10)
|
66
|
+
|
67
|
+
## [v0.6.4](https://github.com/mwrock/kitchen-nodes/tree/v0.6.4) (2016-01-27)
|
68
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.6.0...v0.6.4)
|
69
|
+
|
70
|
+
**Fixed bugs:**
|
71
|
+
|
72
|
+
- Error: Sandbox directory has not yet been created [\#9](https://github.com/mwrock/kitchen-nodes/issues/9)
|
73
|
+
|
74
|
+
## [v0.6.0](https://github.com/mwrock/kitchen-nodes/tree/v0.6.0) (2015-12-14)
|
75
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.5.0...v0.6.0)
|
76
|
+
|
77
|
+
**Implemented enhancements:**
|
78
|
+
|
79
|
+
- Expand the run\_list into the automatic=\>recipes attribute [\#8](https://github.com/mwrock/kitchen-nodes/pull/8) ([eherot](https://github.com/eherot))
|
80
|
+
|
81
|
+
## [v0.5.0](https://github.com/mwrock/kitchen-nodes/tree/v0.5.0) (2015-10-11)
|
82
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.4.1...v0.5.0)
|
83
|
+
|
84
|
+
**Implemented enhancements:**
|
85
|
+
|
86
|
+
- Feature/adding fqdn [\#7](https://github.com/mwrock/kitchen-nodes/pull/7) ([faja](https://github.com/faja))
|
87
|
+
|
88
|
+
## [v0.4.1](https://github.com/mwrock/kitchen-nodes/tree/v0.4.1) (2015-08-14)
|
89
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.4.0...v0.4.1)
|
90
|
+
|
91
|
+
## [v0.4.0](https://github.com/mwrock/kitchen-nodes/tree/v0.4.0) (2015-08-12)
|
92
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.3.4...v0.4.0)
|
93
|
+
|
94
|
+
## [v0.3.4](https://github.com/mwrock/kitchen-nodes/tree/v0.3.4) (2015-08-04)
|
95
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.3.3...v0.3.4)
|
96
|
+
|
97
|
+
## [v0.3.3](https://github.com/mwrock/kitchen-nodes/tree/v0.3.3) (2015-07-30)
|
98
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.3.2...v0.3.3)
|
99
|
+
|
100
|
+
**Implemented enhancements:**
|
101
|
+
|
102
|
+
- Update IP finder to work for CentOS 7.1 [\#6](https://github.com/mwrock/kitchen-nodes/pull/6) ([joerocklin](https://github.com/joerocklin))
|
103
|
+
|
104
|
+
## [v0.3.2](https://github.com/mwrock/kitchen-nodes/tree/v0.3.2) (2015-06-26)
|
105
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.3.1...v0.3.2)
|
106
|
+
|
107
|
+
**Fixed bugs:**
|
108
|
+
|
109
|
+
- Fix search\(\) for currently provisioned node [\#4](https://github.com/mwrock/kitchen-nodes/pull/4) ([ustuehler](https://github.com/ustuehler))
|
110
|
+
|
111
|
+
## [v0.3.1](https://github.com/mwrock/kitchen-nodes/tree/v0.3.1) (2015-05-11)
|
112
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.3.0...v0.3.1)
|
113
|
+
|
114
|
+
## [v0.3.0](https://github.com/mwrock/kitchen-nodes/tree/v0.3.0) (2015-05-10)
|
115
|
+
[Full Changelog](https://github.com/mwrock/kitchen-nodes/compare/v0.2.0...v0.3.0)
|
116
|
+
|
117
|
+
**Implemented enhancements:**
|
118
|
+
|
119
|
+
- Include .kitchen.yml attributes to the node file at 'normal' scope. [\#2](https://github.com/mwrock/kitchen-nodes/pull/2) ([jcejohnson](https://github.com/jcejohnson))
|
120
|
+
|
121
|
+
## [v0.2.0](https://github.com/mwrock/kitchen-nodes/tree/v0.2.0) (2015-04-21)
|
122
|
+
|
123
|
+
|
124
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Author:: Matt Wrock (<matt@mattwrock.com>)
|
2
|
+
|
3
|
+
Copyright (C) 2015, Matt Wrock
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
# <a name="title"></a> Kitchen::Nodes
|
2
|
+
|
3
|
+
A Test Kitchen Provisioner that generates searchable Nodes.
|
4
|
+
|
5
|
+
The nodes provisioner extends the `chef-zero` provisioner along with all of its functionality and configuration. `chef-zero` can support chef searches by querying against node data stored in json files inside of the kitchen `nodes` folder. The `kitchen-nodes` plugin automatically generates a node file when a test instance is provisioned by test-kitchen.
|
6
|
+
|
7
|
+
### Example nodes:
|
8
|
+
|
9
|
+
```
|
10
|
+
{
|
11
|
+
"id": "server-community-ubuntu-1204",
|
12
|
+
"automatic": {
|
13
|
+
"ipaddress": "172.17.0.8",
|
14
|
+
"platform": "ubuntu",
|
15
|
+
"recipes": [
|
16
|
+
"apt::default",
|
17
|
+
"couchbase-tests::ipaddress",
|
18
|
+
"couchbase::server",
|
19
|
+
"export-node"
|
20
|
+
]
|
21
|
+
},
|
22
|
+
"normal": {
|
23
|
+
"attr1": "val1"
|
24
|
+
}
|
25
|
+
"run_list": [
|
26
|
+
"recipe[apt]",
|
27
|
+
"recipe[couchbase-tests::ipaddress]",
|
28
|
+
"recipe[couchbase::server]",
|
29
|
+
"recipe[export-node]"
|
30
|
+
]
|
31
|
+
}
|
32
|
+
|
33
|
+
{
|
34
|
+
"id": "second-node-ubuntu-1204",
|
35
|
+
"automatic": {
|
36
|
+
"ipaddress": "172.17.0.9",
|
37
|
+
"platform": "ubuntu",
|
38
|
+
"recipes": [
|
39
|
+
"apt::default",
|
40
|
+
"couchbase-tests::ipaddress",
|
41
|
+
"couchbase::server",
|
42
|
+
"export-node"
|
43
|
+
]
|
44
|
+
},
|
45
|
+
"run_list": [
|
46
|
+
"recipe[apt]",
|
47
|
+
"recipe[couchbase-tests::ipaddress]",
|
48
|
+
"recipe[couchbase-tests::default]",
|
49
|
+
"recipe[export-node]"
|
50
|
+
]
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
54
|
+
The node data includes the node id based on the test-kitchen suite name, the run list assigned to the node, the normal attributes included in the `.kitchen.yml` file, the externally reachable ip address and the platform of the test instance os.
|
55
|
+
|
56
|
+
## <a name="installation"></a> Installation
|
57
|
+
|
58
|
+
```
|
59
|
+
gem install kitchen-nodes
|
60
|
+
```
|
61
|
+
|
62
|
+
## <a name="config"></a> Configuration
|
63
|
+
|
64
|
+
Use `nodes` instead of `chef-zero` for the kitchen provisioner name.
|
65
|
+
|
66
|
+
```
|
67
|
+
provisioner:
|
68
|
+
name: nodes
|
69
|
+
```
|
70
|
+
|
71
|
+
## <a name="Usage"></a> Usage
|
72
|
+
|
73
|
+
Using `kitchen-nodes` one can expect all previously converged nodes to be represented in a node file and be searchable. For example consider this scenario looking for a primary node in a cluster in order to add a node to join:
|
74
|
+
|
75
|
+
```
|
76
|
+
require 'timeout'
|
77
|
+
|
78
|
+
def search_for_nodes(query, timeout = 120)
|
79
|
+
nodes = []
|
80
|
+
Timeout::timeout(timeout) do
|
81
|
+
nodes = search(:node, query)
|
82
|
+
until nodes.count > 0 && nodes[0].has_key?('ipaddress')
|
83
|
+
sleep 5
|
84
|
+
nodes = search(:node, query)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if nodes.count == 0 || !nodes[0].has_key?('ipaddress')
|
89
|
+
raise "Unable to find nodes!"
|
90
|
+
end
|
91
|
+
|
92
|
+
nodes
|
93
|
+
end
|
94
|
+
|
95
|
+
primary = search_for_nodes("run_list:*couchbase??server* AND platform:#{node['platform']}")
|
96
|
+
node.normal["couchbase-tests"]["primary_ip"] = primary[0]['ipaddress']
|
97
|
+
|
98
|
+
```
|
99
|
+
### <a name="vagrant"></a> Using with Vagrant
|
100
|
+
|
101
|
+
When using kitchen-nodes with the vagrant driver, make sure you add the following to your `driver_config`:
|
102
|
+
|
103
|
+
```
|
104
|
+
network:
|
105
|
+
- ["private_network", { type: "dhcp" }]
|
106
|
+
```
|
107
|
+
|
108
|
+
This will add an additional non-NAT NIC to your vagrant box with an IP reachable from the host and other test nodes.
|
109
|
+
|
110
|
+
### <a name="virtualbox"></a> Why is my ohai `ipaddress` different from my node ipaddress on vagrant with VirtualBox?
|
111
|
+
|
112
|
+
Ohai will pick up the localhost ipaddress on vagrant boxes using virtualbox. To reset the `node["ipaddress"]` to the reachable ip, add `hurry-up-and-test::set_non_nat_vbox_ip` to the top of your `run_list`.
|
113
|
+
|
114
|
+
```
|
115
|
+
suites:
|
116
|
+
- name: my-suite
|
117
|
+
run_list:
|
118
|
+
- recipe[hurry-up-and-test::set_non_nat_vbox_ip]
|
119
|
+
- recipe[cookbook-under-test]
|
120
|
+
```
|
121
|
+
|
122
|
+
You can add this even if you do not use virtualbox and the recipe will do nothing.
|
123
|
+
|
124
|
+
|
125
|
+
## <a name="development"></a> Development
|
126
|
+
|
127
|
+
* Source hosted at [GitHub][repo]
|
128
|
+
* Report issues/questions/feature requests on [GitHub Issues][issues]
|
129
|
+
|
130
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
131
|
+
Ideally create a topic branch for every separate change you make. For
|
132
|
+
example:
|
133
|
+
|
134
|
+
1. Fork the repo
|
135
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
136
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
137
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
138
|
+
5. Create new Pull Request
|
139
|
+
|
140
|
+
## <a name="authors"></a> Authors
|
141
|
+
|
142
|
+
Created and maintained by [Matt Wrock][author] (<matt@mattwrock.com>)
|
143
|
+
|
144
|
+
## <a name="license"></a> License
|
145
|
+
|
146
|
+
Apache 2.0 (see [LICENSE][license])
|
147
|
+
|
148
|
+
|
149
|
+
[author]: https://github.com/mwrock
|
150
|
+
[issues]: https://github.com/mwrock/kitchen-nodes/issues
|
151
|
+
[license]: https://github.com/mwrock/kitchen-nodes/blob/master/LICENSE
|
152
|
+
[repo]: https://github.com/mwrock/kitchen-nodes
|
153
|
+
[driver_usage]: http://docs.kitchen-ci.org/drivers/usage
|
154
|
+
[chef_omnibus_dl]: http://www.getchef.com/chef/install/
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'github_changelog_generator/task'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:test)
|
7
|
+
|
8
|
+
RuboCop::RakeTask.new(:style) do |task|
|
9
|
+
task.options << '--display-cop-names'
|
10
|
+
end
|
11
|
+
|
12
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
13
|
+
config.future_release = Kitchen::Provisioner::NODES_VERSION
|
14
|
+
config.enhancement_labels = ['enhancement']
|
15
|
+
config.bug_labels = ['bug']
|
16
|
+
config.exclude_labels = %w(duplicate question invalid wontfix no_changelog)
|
17
|
+
config.exclude_tags = [
|
18
|
+
'v0.1.0.dev', 'v0.2.0.dev', 'v0.2.0.dev.1',
|
19
|
+
'v0.2.0.dev.2', 'v0.2.0.dev.3', 'v0.2.0.dev.4',
|
20
|
+
'v0.6.4.dev', 'v0.6.3', 'v0.6.2', 'v0.6.1'
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
task default: [:test, :style]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kitchen/provisioner/nodes_version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'kitchen-nodes-scalp42'
|
8
|
+
spec.version = Kitchen::Provisioner::NODES_VERSION
|
9
|
+
spec.authors = ['Matt Wrock']
|
10
|
+
spec.email = ['matt@mattwrock.com']
|
11
|
+
spec.description = 'A Test Kitchen Provisioner for Chef Nodes'
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'Apache 2.0'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = []
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'net-ping'
|
22
|
+
spec.add_dependency 'win32-security'
|
23
|
+
spec.add_dependency 'test-kitchen', '~> 1.13'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'fakefs', '~> 0.4'
|
27
|
+
spec.add_development_dependency 'github_changelog_generator', '1.11.3'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.37', '>= 0.37.1'
|
31
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Kitchen
|
2
|
+
module Transport
|
3
|
+
class Ssh < Kitchen::Transport::Base
|
4
|
+
# Monkey patch of test-kitchen ssh transport
|
5
|
+
# that returns stdout
|
6
|
+
class Connection < Kitchen::Transport::Base::Connection
|
7
|
+
def node_execute(command, &block)
|
8
|
+
return if command.nil?
|
9
|
+
out, exit_code = node_execute_with_exit_code(command, &block)
|
10
|
+
|
11
|
+
if exit_code.nonzero?
|
12
|
+
raise Transport::SshFailed,
|
13
|
+
"SSH exited (#{exit_code}) for command: [#{command}]"
|
14
|
+
end
|
15
|
+
out
|
16
|
+
rescue Net::SSH::Exception => ex
|
17
|
+
raise SshFailed, "SSH command failed (#{ex.message})"
|
18
|
+
end
|
19
|
+
|
20
|
+
# rubocop:disable Metrics/AbcSize
|
21
|
+
def node_execute_with_exit_code(command)
|
22
|
+
exit_code = nil
|
23
|
+
out = []
|
24
|
+
session.open_channel do |channel|
|
25
|
+
channel.request_pty
|
26
|
+
channel.exec(command) do |_ch, _success|
|
27
|
+
channel.on_data do |_ch, data|
|
28
|
+
out << data
|
29
|
+
yield data if block_given?
|
30
|
+
end
|
31
|
+
|
32
|
+
channel.on_extended_data do |_ch, _type, data|
|
33
|
+
out << data
|
34
|
+
yield data if block_given?
|
35
|
+
end
|
36
|
+
|
37
|
+
channel.on_request('exit-status') do |_ch, data|
|
38
|
+
exit_code = data.read_long
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
session.loop
|
43
|
+
[out.join("\n"), exit_code]
|
44
|
+
end
|
45
|
+
# rubocop:enable Metrics/AbcSize
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module Provisioner
|
51
|
+
module Finder
|
52
|
+
# SSH implementation for returning active non-localhost IPs
|
53
|
+
class Ssh
|
54
|
+
IP4REGEX = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
55
|
+
|
56
|
+
Finder.register_finder(Kitchen::Transport::Ssh, self)
|
57
|
+
|
58
|
+
def initialize(connection)
|
59
|
+
@connection = connection
|
60
|
+
end
|
61
|
+
|
62
|
+
def find_ips
|
63
|
+
ips = []
|
64
|
+
5.times do
|
65
|
+
begin
|
66
|
+
ips = run_ifconfig
|
67
|
+
rescue Kitchen::Transport::TransportFailed
|
68
|
+
ips = run_ip_addr
|
69
|
+
end
|
70
|
+
return ips unless ips.empty?
|
71
|
+
sleep 0.5
|
72
|
+
end
|
73
|
+
ips
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_fqdn
|
77
|
+
@connection.node_execute('hostname -f').chomp.chomp
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def run_ifconfig
|
83
|
+
response = @connection.node_execute('/sbin/ifconfig -a')
|
84
|
+
ips = []
|
85
|
+
response.split(/^\S+/).each do |device|
|
86
|
+
next if !device.include?('RUNNING') || device.include?('LOOPBACK')
|
87
|
+
next if IP4REGEX.match(device).nil?
|
88
|
+
ips << IP4REGEX.match(device)[1]
|
89
|
+
end
|
90
|
+
ips.compact
|
91
|
+
end
|
92
|
+
|
93
|
+
def run_ip_addr
|
94
|
+
response = @connection.node_execute('/sbin/ip -4 addr show')
|
95
|
+
ips = []
|
96
|
+
response.split(/^[0-9]+: /).each do |device|
|
97
|
+
next if device.include?('LOOPBACK') || device.include?('NO-CARRIER')
|
98
|
+
next if device == ''
|
99
|
+
found_ips = IP4REGEX.match(device)
|
100
|
+
ips << IP4REGEX.match(device)[1] unless found_ips.nil?
|
101
|
+
end
|
102
|
+
ips.compact
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|