kitchen-chefzero-nodes 1.0.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 +7 -0
- data/.gitignore +17 -0
- data/.kitchen.yml +46 -0
- data/.rubocop.yml +30 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +23 -0
- data/README.md +69 -0
- data/Rakefile +41 -0
- data/kitchen-chefzero-nodes.gemspec +28 -0
- data/lib/kitchen/provisioner/chef_zero_nodes.rb +175 -0
- data/lib/kitchen/provisioner/chef_zero_nodes_version.rb +24 -0
- data/test/integration/cookbooks/test/Policyfile.rb +7 -0
- data/test/integration/cookbooks/test/metadata.rb +1 -0
- data/test/integration/cookbooks/test/recipes/default.rb +17 -0
- data/test/integration/cookbooks/test/recipes/search.rb +33 -0
- data/test/integration/ssh/serverspec/default_spec.rb +36 -0
- metadata +156 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 44ac7594d4c8c6f1337e404aafa2e32aec4a7faa
|
|
4
|
+
data.tar.gz: cec1c8f38ddd069ccf23be174eb17e3d89d25448
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 57186d05037fe12095c9004335ea302ea3c4c6bd496f45075f6e2f834c26e7ebc956a9174ed626b70ffe7ee968b79588cb65e3b1d98b5dd7dd188cf73de19594
|
|
7
|
+
data.tar.gz: 95c486a953f785d2171c67dd8f35a0e59b0b2cf3974232684c5ff47a34eed44db10eb506deb30f1d746334200987599d19355b024275c371ffce708948a64a82
|
data/.gitignore
ADDED
data/.kitchen.yml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
driver:
|
|
3
|
+
name: vagrant
|
|
4
|
+
provider: parallels
|
|
5
|
+
|
|
6
|
+
provisioner:
|
|
7
|
+
name: chef_zero_nodes
|
|
8
|
+
nodes_path: test/integration/nodes
|
|
9
|
+
policyfile: test/integration/cookbooks/test/Policyfile.rb
|
|
10
|
+
|
|
11
|
+
platforms:
|
|
12
|
+
- name: el6
|
|
13
|
+
driver:
|
|
14
|
+
box: bento/centos-6.8
|
|
15
|
+
|
|
16
|
+
- name: win2012R2
|
|
17
|
+
driver:
|
|
18
|
+
box: win-2012r2-base
|
|
19
|
+
customize:
|
|
20
|
+
memsize: 2048
|
|
21
|
+
cpus: 2
|
|
22
|
+
|
|
23
|
+
suites:
|
|
24
|
+
- name: sftp
|
|
25
|
+
transport:
|
|
26
|
+
name: sftp
|
|
27
|
+
provisioner:
|
|
28
|
+
named_run_list: sftp
|
|
29
|
+
excludes:
|
|
30
|
+
- win2012R2
|
|
31
|
+
|
|
32
|
+
- name: winrm
|
|
33
|
+
transport:
|
|
34
|
+
name: winrm
|
|
35
|
+
provisioner:
|
|
36
|
+
named_run_list: win
|
|
37
|
+
excludes:
|
|
38
|
+
- el6
|
|
39
|
+
|
|
40
|
+
- name: ssh
|
|
41
|
+
transport:
|
|
42
|
+
name: ssh
|
|
43
|
+
provisioner:
|
|
44
|
+
named_run_list: ssh
|
|
45
|
+
excludes:
|
|
46
|
+
- win2012R2
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- vendor/**/*
|
|
4
|
+
|
|
5
|
+
AlignParameters:
|
|
6
|
+
Enabled: false
|
|
7
|
+
ClassLength:
|
|
8
|
+
Enabled: false
|
|
9
|
+
CyclomaticComplexity:
|
|
10
|
+
Enabled: false
|
|
11
|
+
Documentation:
|
|
12
|
+
Enabled: false
|
|
13
|
+
Encoding:
|
|
14
|
+
Enabled: false
|
|
15
|
+
Style/FileName:
|
|
16
|
+
Enabled: false
|
|
17
|
+
LineLength:
|
|
18
|
+
Enabled: false
|
|
19
|
+
MethodLength:
|
|
20
|
+
Enabled: false
|
|
21
|
+
Metrics/AbcSize:
|
|
22
|
+
Enabled: false
|
|
23
|
+
PerceivedComplexity:
|
|
24
|
+
Enabled: false
|
|
25
|
+
Style/SpaceBeforeFirstArg:
|
|
26
|
+
Enabled: false
|
|
27
|
+
Style/ClassAndModuleChildren:
|
|
28
|
+
Enabled: false
|
|
29
|
+
Style/FileName:
|
|
30
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gemspec
|
|
4
|
+
|
|
5
|
+
group :rake do
|
|
6
|
+
gem 'rake'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
group :lint do
|
|
10
|
+
gem 'rubocop', '~> 0.37'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
group :unit do
|
|
14
|
+
gem 'chefspec', '~> 4.5'
|
|
15
|
+
gem 'rspec', '~> 3.0'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
group :kitchen do
|
|
19
|
+
gem 'chef-dk', '~> 0.10'
|
|
20
|
+
gem 'test-kitchen', '~> 1.5'
|
|
21
|
+
gem 'kitchen-sync', '~> 2.0'
|
|
22
|
+
gem 'kitchen-vagrant', '~> 0.19'
|
|
23
|
+
end
|
data/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Kitchen::ChefZeroNodes
|
|
2
|
+
|
|
3
|
+
Provisioner `chef_zero_nodes` extends `chef_zero` by adding one more step in the end of converge - it downloads the resulted node
|
|
4
|
+
JSON object to the `nodes_path` on the host machine after successful converge. It allows you to use this node object for searches while converging another
|
|
5
|
+
Test Kitchen suites. So, you can use actual node attributes like ipaddress/fqdn to communicate nodes with each other.
|
|
6
|
+
|
|
7
|
+
For example, 'web' node need to search 'db' node ip.
|
|
8
|
+
In `chef_zero` we have to create mock in node_path for this search. `chef_zero_nodes` will save mock automatically after 'db' successful converge.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
* ChefDK 0.12.0+
|
|
13
|
+
* Test Kitchen 1.10+
|
|
14
|
+
|
|
15
|
+
## Supports
|
|
16
|
+
|
|
17
|
+
* Linux
|
|
18
|
+
* Windows 2012 RC2
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
gem install kitchen-chefzero-nodes
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
Use `chef_zero_nodes` instead of `chef_zero` for the kitchen provisioner name.
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
provisioner:
|
|
32
|
+
name: chef_zero_nodes
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
* Source hosted at [GitHub](https://github.com/scopenco/kitchen-chefzero-nodes)
|
|
38
|
+
* Report issues/questions/feature requests on [GitHub Issues](https://github.com/scopenco/kitchen-chefzero-nodes/issues)
|
|
39
|
+
|
|
40
|
+
Pull requests are very welcome! Make sure your patches are well tested.
|
|
41
|
+
Ideally create a topic branch for every separate change you make. For
|
|
42
|
+
example:
|
|
43
|
+
|
|
44
|
+
1. Fork the repo
|
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
46
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
48
|
+
5. Create new Pull Request
|
|
49
|
+
|
|
50
|
+
## Testing
|
|
51
|
+
|
|
52
|
+
1. Run `bundle install`
|
|
53
|
+
2. Run `rake` for unit testing
|
|
54
|
+
|
|
55
|
+
## Authors
|
|
56
|
+
|
|
57
|
+
Created and maintained by [Andrei Skopenko][author] (<andrei@skopenko.net>)
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
Apache 2.0
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
[author]: https://github.com/scopenco
|
|
65
|
+
[issues]: https://github.com/scopenco/kitchen-policyfile-nodes/issues
|
|
66
|
+
[license]: https://github.com/scopenco/kitchen-policyfile-nodes/blob/master/LICENSE
|
|
67
|
+
[repo]: https://github.com/scopenco/kitchen-policyfile-nodes
|
|
68
|
+
[driver_usage]: http://docs.kitchen-ci.org/drivers/usage
|
|
69
|
+
[chef_omnibus_dl]: http://www.getchef.com/chef/install/
|
data/Rakefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'rubocop/rake_task'
|
|
6
|
+
require 'kitchen'
|
|
7
|
+
require 'chef-dk/cli'
|
|
8
|
+
|
|
9
|
+
# Rubocop
|
|
10
|
+
desc 'Run Ruby style checks'
|
|
11
|
+
RuboCop::RakeTask.new(:rubocop)
|
|
12
|
+
|
|
13
|
+
# Rspec
|
|
14
|
+
desc 'Run ChefSpec examples'
|
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
16
|
+
|
|
17
|
+
# Integration tests. Kitchen.ci
|
|
18
|
+
namespace :integration do
|
|
19
|
+
desc 'Run Test Kitchen with Vagrant'
|
|
20
|
+
task :vagrant do
|
|
21
|
+
Kitchen.logger = Kitchen.default_file_logger
|
|
22
|
+
Kitchen::Config.new.instances.each do |instance|
|
|
23
|
+
instance.test(:verify)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
namespace :policyfile do
|
|
29
|
+
desc 'Run "chef update" for Policyfile.rb'
|
|
30
|
+
task :update do
|
|
31
|
+
Dir.glob('test/integration/cookbooks/test/Policyfile.rb').each do |file|
|
|
32
|
+
cli = ChefDK::CLI.new(['update', file])
|
|
33
|
+
subcommand_name, *subcommand_params = cli.argv
|
|
34
|
+
subcommand = cli.instantiate_subcommand(subcommand_name)
|
|
35
|
+
subcommand.run_with_default_options(subcommand_params)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Default
|
|
41
|
+
task default: ['rubocop', 'spec', 'policyfile:update', 'integration:vagrant']
|
|
@@ -0,0 +1,28 @@
|
|
|
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/chef_zero_nodes_version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'kitchen-chefzero-nodes'
|
|
8
|
+
spec.version = Kitchen::Provisioner::CHEF_ZERO_NODES_VERSION
|
|
9
|
+
spec.authors = ['Andrei Skopenko']
|
|
10
|
+
spec.email = ['andrei@skopenko.net']
|
|
11
|
+
spec.description = 'Test Kitchen provisioner based on chef_zero that generates searchable nodes'
|
|
12
|
+
spec.summary = spec.description
|
|
13
|
+
spec.homepage = 'https://github.com/Parallels/kitchen-chefzero-nodes'
|
|
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 'test-kitchen', '~> 1.7'
|
|
22
|
+
spec.add_dependency 'chef-dk', '~> 0.12'
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
25
|
+
spec.add_development_dependency 'rake'
|
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.37', '>= 0.37.1'
|
|
28
|
+
end
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Andrei Skopenko (<andrei@skopenko.net>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2015 Andrei Skopenko
|
|
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 'kitchen/provisioner/chef_zero'
|
|
20
|
+
require 'kitchen/provisioner/base'
|
|
21
|
+
require 'kitchen/driver/ssh_base'
|
|
22
|
+
require 'kitchen/transport/ssh'
|
|
23
|
+
require 'kitchen/transport/winrm'
|
|
24
|
+
|
|
25
|
+
# continue loading if kitchen-sync not installed
|
|
26
|
+
begin
|
|
27
|
+
require 'kitchen/transport/sftp'
|
|
28
|
+
rescue LoadError
|
|
29
|
+
puts 'Ignoring sftp transport...'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
module Kitchen
|
|
33
|
+
module Driver
|
|
34
|
+
class SSHBase
|
|
35
|
+
# ChefZeroNodes needs to access to legacy_ssh_base_converge method
|
|
36
|
+
# used by some drivers like kithen-vz. This method
|
|
37
|
+
# add additional command after chef_client run complete.
|
|
38
|
+
#
|
|
39
|
+
# @param state [Hash] mutable instance state
|
|
40
|
+
# @raise [ActionFailed] if the action could not be completed
|
|
41
|
+
def converge(state)
|
|
42
|
+
provisioner = instance.provisioner
|
|
43
|
+
provisioner.create_sandbox
|
|
44
|
+
sandbox_dirs = Dir.glob("#{provisioner.sandbox_path}/*")
|
|
45
|
+
instance.transport.connection(backcompat_merged_state(state)) do |conn|
|
|
46
|
+
conn.execute(env_cmd(provisioner.install_command))
|
|
47
|
+
conn.execute(env_cmd(provisioner.init_command))
|
|
48
|
+
info("Transferring files to #{instance.to_str}")
|
|
49
|
+
conn.upload(sandbox_dirs, provisioner[:root_path])
|
|
50
|
+
debug('Transfer complete')
|
|
51
|
+
conn.execute(env_cmd(provisioner.prepare_command))
|
|
52
|
+
conn.execute(env_cmd(provisioner.run_command))
|
|
53
|
+
# Download node json object generated by chef_client
|
|
54
|
+
info("Transferring #{provisioner.unix_int_node_file} " \
|
|
55
|
+
"from instance to #{provisioner.ext_node_file}")
|
|
56
|
+
conn.execute(env_cmd(conn.download(provisioner.unix_int_node_file,
|
|
57
|
+
provisioner.ext_node_file)))
|
|
58
|
+
debug('Transfer complete')
|
|
59
|
+
end
|
|
60
|
+
rescue Kitchen::Transport::TransportFailed => ex
|
|
61
|
+
raise ActionFailed, ex.message
|
|
62
|
+
ensure
|
|
63
|
+
instance.provisioner.cleanup_sandbox
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
module Kitchen
|
|
70
|
+
module Transport
|
|
71
|
+
class Ssh
|
|
72
|
+
class Connection
|
|
73
|
+
# Download JSON node file from instance to
|
|
74
|
+
# node_path over SCP
|
|
75
|
+
#
|
|
76
|
+
# @param remote [String] file path on instance
|
|
77
|
+
# @param local [String] file path on host
|
|
78
|
+
def download(remote, local)
|
|
79
|
+
FileUtils.mkdir_p(File.dirname(local))
|
|
80
|
+
session.scp.download!(remote, local, {})
|
|
81
|
+
logger.debug("Downloaded #{remote} to #{local}")
|
|
82
|
+
rescue Net::SSH::Exception => ex
|
|
83
|
+
raise SshFailed, "SCP download failed (#{ex.message})"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
module Kitchen
|
|
91
|
+
module Transport
|
|
92
|
+
class Winrm
|
|
93
|
+
class Connection
|
|
94
|
+
# Download JSON node file from instance to
|
|
95
|
+
# node_path over Winrm
|
|
96
|
+
#
|
|
97
|
+
# @param remote [String] file path on instance
|
|
98
|
+
# @param local [String] file path on host
|
|
99
|
+
# TODO need to fix scheme
|
|
100
|
+
def download(remote, local)
|
|
101
|
+
FileUtils.mkdir_p(File.dirname(local))
|
|
102
|
+
file_manager ||= WinRM::FS::FileManager.new(service)
|
|
103
|
+
file_manager.download(remote, local)
|
|
104
|
+
logger.debug("Downloaded #{remote} to #{local}")
|
|
105
|
+
rescue Kitchen::Transport::WinrmFailed => ex
|
|
106
|
+
raise WinrmFailed, "Winrm download failed (#{ex.message})"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
module Kitchen
|
|
114
|
+
module Provisioner
|
|
115
|
+
class Base
|
|
116
|
+
# ChefZeroNodes needs to access to provision of the instance
|
|
117
|
+
# without invoking the behavior of Base#call because we need to
|
|
118
|
+
# add additional command after chef_client run complete.
|
|
119
|
+
#
|
|
120
|
+
# @param state [Hash] mutable instance state
|
|
121
|
+
# @raise [ActionFailed] if the action could not be completed
|
|
122
|
+
def call(state)
|
|
123
|
+
create_sandbox
|
|
124
|
+
sandbox_dirs = Dir.glob(File.join(sandbox_path, '*'))
|
|
125
|
+
|
|
126
|
+
instance.transport.connection(state) do |conn|
|
|
127
|
+
conn.execute(install_command)
|
|
128
|
+
conn.execute(init_command)
|
|
129
|
+
info("Transferring files to #{instance.to_str}")
|
|
130
|
+
conn.upload(sandbox_dirs, config[:root_path])
|
|
131
|
+
debug('Transfer complete')
|
|
132
|
+
conn.execute(prepare_command)
|
|
133
|
+
conn.execute(run_command)
|
|
134
|
+
# Download node json object generated by chef_client
|
|
135
|
+
int_node_file = windows_os? ? win_int_node_file : unix_int_node_file
|
|
136
|
+
info("Transferring #{int_node_file} " \
|
|
137
|
+
"from instance to #{ext_node_file}")
|
|
138
|
+
conn.download(int_node_file, ext_node_file)
|
|
139
|
+
debug('Transfer complete')
|
|
140
|
+
end
|
|
141
|
+
rescue Kitchen::Transport::TransportFailed => ex
|
|
142
|
+
raise ActionFailed, ex.message
|
|
143
|
+
ensure
|
|
144
|
+
cleanup_sandbox
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
class ChefZero
|
|
149
|
+
# ChefZeroNodes needs to access the base behavior of creating the
|
|
150
|
+
# sandbox directory without invoking the behavior of
|
|
151
|
+
# ChefZero#create_sandbox, we need to override json node.
|
|
152
|
+
alias create_chefzero_sandbox create_sandbox
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
class ChefZeroNodes < ChefZero
|
|
156
|
+
# (see ChefZero#create_sandbox)
|
|
157
|
+
def create_sandbox
|
|
158
|
+
FileUtils.rm(ext_node_file) if File.exist?(ext_node_file)
|
|
159
|
+
create_chefzero_sandbox
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def ext_node_file
|
|
163
|
+
File.join(config[:nodes_path], "#{instance.name}.json")
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def unix_int_node_file
|
|
167
|
+
File.join(config[:root_path], 'nodes', "#{instance.name}.json")
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def win_int_node_file
|
|
171
|
+
File.join(config[:root_path], 'nodes', "#{instance.name}.json").tr('/', '\\')
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Andrei Skopenko (<andrei@skopenko.net>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2015 Andrei Skopenko
|
|
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
|
+
module Kitchen
|
|
20
|
+
# Version string for chefzero_nodes Kitchen driver
|
|
21
|
+
module Provisioner
|
|
22
|
+
CHEF_ZERO_NODES_VERSION = '1.0.0'.freeze
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
name 'test'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: test
|
|
3
|
+
# Resource:: default
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2015 Andrei Skopenko
|
|
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.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: test
|
|
3
|
+
# Resource:: search
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2015 Andrei Skopenko
|
|
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
|
+
sftp_node = search(:node, "name:sftp-* AND platform:#{node['platform']}")
|
|
20
|
+
ruby_block 'save sftp attributes' do
|
|
21
|
+
block do
|
|
22
|
+
parent = File.join(ENV['TEMP'] || '/tmp', 'kitchen')
|
|
23
|
+
IO.write(File.join(parent, 'sftp.json'), sftp_node[0].to_json)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
win_node = search(:node, 'platform:windows')
|
|
28
|
+
ruby_block 'save win attributes' do
|
|
29
|
+
block do
|
|
30
|
+
parent = File.join(ENV['TEMP'] || '/tmp', 'kitchen')
|
|
31
|
+
IO.write(File.join(parent, 'win.json'), win_node[0].to_json)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'serverspec'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
set :backend, :exec
|
|
5
|
+
|
|
6
|
+
describe 'sftp node' do
|
|
7
|
+
let(:node) do
|
|
8
|
+
JSON.parse(
|
|
9
|
+
IO.read(File.join(ENV['TEMP'] || '/tmp', 'kitchen/sftp.json'))
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'has ip' do
|
|
14
|
+
expect(node['automatic'].key?('ipaddress')).to eq(true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'has fqdn' do
|
|
18
|
+
expect(node['automatic'].key?('fqdn')).to eq(true)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'win node' do
|
|
23
|
+
let(:node) do
|
|
24
|
+
JSON.parse(
|
|
25
|
+
IO.read(File.join(ENV['TEMP'] || '/tmp', 'kitchen/win.json'))
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'has ip' do
|
|
30
|
+
expect(node['automatic'].key?('ipaddress')).to eq(true)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'has fqdn' do
|
|
34
|
+
expect(node['automatic'].key?('fqdn')).to eq(true)
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: kitchen-chefzero-nodes
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrei Skopenko
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-09-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: test-kitchen
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.7'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: chef-dk
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.12'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.12'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.3'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.3'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.2'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.2'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0.37'
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: 0.37.1
|
|
93
|
+
type: :development
|
|
94
|
+
prerelease: false
|
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - "~>"
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0.37'
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: 0.37.1
|
|
103
|
+
description: Test Kitchen provisioner based on chef_zero that generates searchable
|
|
104
|
+
nodes
|
|
105
|
+
email:
|
|
106
|
+
- andrei@skopenko.net
|
|
107
|
+
executables: []
|
|
108
|
+
extensions: []
|
|
109
|
+
extra_rdoc_files: []
|
|
110
|
+
files:
|
|
111
|
+
- ".gitignore"
|
|
112
|
+
- ".kitchen.yml"
|
|
113
|
+
- ".rubocop.yml"
|
|
114
|
+
- CHANGELOG.md
|
|
115
|
+
- Gemfile
|
|
116
|
+
- README.md
|
|
117
|
+
- Rakefile
|
|
118
|
+
- kitchen-chefzero-nodes.gemspec
|
|
119
|
+
- lib/kitchen/provisioner/chef_zero_nodes.rb
|
|
120
|
+
- lib/kitchen/provisioner/chef_zero_nodes_version.rb
|
|
121
|
+
- test/integration/cookbooks/test/Policyfile.rb
|
|
122
|
+
- test/integration/cookbooks/test/metadata.rb
|
|
123
|
+
- test/integration/cookbooks/test/recipes/default.rb
|
|
124
|
+
- test/integration/cookbooks/test/recipes/search.rb
|
|
125
|
+
- test/integration/ssh/serverspec/default_spec.rb
|
|
126
|
+
homepage: https://github.com/Parallels/kitchen-chefzero-nodes
|
|
127
|
+
licenses:
|
|
128
|
+
- Apache 2.0
|
|
129
|
+
metadata: {}
|
|
130
|
+
post_install_message:
|
|
131
|
+
rdoc_options: []
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - ">="
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: '0'
|
|
144
|
+
requirements: []
|
|
145
|
+
rubyforge_project:
|
|
146
|
+
rubygems_version: 2.6.4
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: Test Kitchen provisioner based on chef_zero that generates searchable nodes
|
|
150
|
+
test_files:
|
|
151
|
+
- test/integration/cookbooks/test/Policyfile.rb
|
|
152
|
+
- test/integration/cookbooks/test/metadata.rb
|
|
153
|
+
- test/integration/cookbooks/test/recipes/default.rb
|
|
154
|
+
- test/integration/cookbooks/test/recipes/search.rb
|
|
155
|
+
- test/integration/ssh/serverspec/default_spec.rb
|
|
156
|
+
has_rdoc:
|