kitchen-policyfile-nodes 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd3001fe7b97d7e286bf216736e46e7a2e154e26
4
- data.tar.gz: 0ad6b3d0d2f563dbdb9843479ff72db3703f0b36
3
+ metadata.gz: 60713a800964889583b52f98ead21b7d8784d003
4
+ data.tar.gz: f7e703225d95591709017977c71331c189409b5b
5
5
  SHA512:
6
- metadata.gz: 92a9977dc49c2c681293a0fbff203d5ace3cc9c9f62d5051d01e31e2713d3f01f34e31f30ff7414501ddd9f2da42ea64123013b0c8fbfa17285b28740872aecb
7
- data.tar.gz: a752e3cf02a01bacc1db2423db52b94758677b56b1750bfd76f88f73abb432bebef11a7c93d2bbf05c171b24d35b503b0f89b5e4749c1421e63fdf7cc1e94c83
6
+ metadata.gz: f7a53f6008d89425ac7a23060cba77b58b18664e86428616dfc3d9987d3779349632e02aec45c40348751a8f456a585dd49002203314609ba6c375e2e6bfc4e8
7
+ data.tar.gz: 35a1260f626f4f80894c3a42e109fd16a582396a220702a71d1776c15af94c2a5082a05d75a4dff51543ac82b3812faef83110130d6e418db532b09d38b4939c
@@ -12,15 +12,34 @@ platforms:
12
12
  driver:
13
13
  box: bento/centos-6.7
14
14
 
15
+ - name: win2012R2
16
+ driver:
17
+ box: win-2012r2-base
18
+ customize:
19
+ memsize: 2048
20
+ cpus: 2
21
+
15
22
  suites:
16
23
  - name: sftp
17
24
  transport:
18
25
  name: sftp
19
26
  provisioner:
20
27
  named_run_list: sftp
28
+ excludes:
29
+ - win2012R2
30
+
31
+ - name: winrm
32
+ transport:
33
+ name: winrm
34
+ provisioner:
35
+ named_run_list: win
36
+ excludes:
37
+ - el6
21
38
 
22
39
  - name: ssh
23
40
  transport:
24
41
  name: ssh
25
42
  provisioner:
26
43
  named_run_list: ssh
44
+ excludes:
45
+ - win2012R2
data/README.md CHANGED
@@ -1,15 +1,21 @@
1
1
  # Kitchen::PolicyfileNodes
2
2
 
3
3
  Provisioner `policyfile_nodes` extends `policyfile_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 over SSH. It allows you to use this node object for searches while converging another
5
- Test Kitchen suites. So, you can use actual node IP addresses to communicate nodes with each other.
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
6
 
7
7
  For example, 'web' node need to search 'db' node ip.
8
8
  In `policyfile_zero` we have to create mock in node_path for this search. `policyfile_nodes` will create mock automatically.
9
9
 
10
10
  ## Requirements
11
11
 
12
- * ChefDK 0.10.0+
12
+ * ChefDK 0.12.0+
13
+ * Test Kitchen 1.7.3+
14
+
15
+ ## Supports
16
+
17
+ * Linux
18
+ * Windows 2012 RC2
13
19
 
14
20
  ## Installation
15
21
 
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'test-kitchen', '~> 1.5'
22
- spec.add_dependency 'chef-dk', '~> 0.10'
21
+ spec.add_dependency 'test-kitchen', '~> 1.7.3'
22
+ spec.add_dependency 'chef-dk', '~> 0.12'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
25
25
  spec.add_development_dependency 'rake'
@@ -20,6 +20,7 @@ require 'kitchen/provisioner/policyfile_zero'
20
20
  require 'kitchen/provisioner/base'
21
21
  require 'kitchen/driver/ssh_base'
22
22
  require 'kitchen/transport/ssh'
23
+ require 'kitchen/transport/winrm'
23
24
 
24
25
  # continue loading if kitchen-sync not installed
25
26
  begin
@@ -50,9 +51,9 @@ module Kitchen
50
51
  conn.execute(env_cmd(provisioner.prepare_command))
51
52
  conn.execute(env_cmd(provisioner.run_command))
52
53
  # Download node json object generated by chef_client
53
- info("Transferring #{provisioner.int_node_file} " \
54
+ info("Transferring #{provisioner.unix_int_node_file} " \
54
55
  "from instance to #{provisioner.ext_node_file}")
55
- conn.execute(env_cmd(conn.download(provisioner.int_node_file,
56
+ conn.execute(env_cmd(conn.download(provisioner.unix_int_node_file,
56
57
  provisioner.ext_node_file)))
57
58
  debug('Transfer complete')
58
59
  end
@@ -86,6 +87,29 @@ module Kitchen
86
87
  end
87
88
  end
88
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
+
89
113
  module Kitchen
90
114
  module Provisioner
91
115
  class Base
@@ -108,6 +132,7 @@ module Kitchen
108
132
  conn.execute(prepare_command)
109
133
  conn.execute(run_command)
110
134
  # Download node json object generated by chef_client
135
+ int_node_file = windows_os? ? win_int_node_file : unix_int_node_file
111
136
  info("Transferring #{int_node_file} " \
112
137
  "from instance to #{ext_node_file}")
113
138
  conn.download(int_node_file, ext_node_file)
@@ -138,9 +163,13 @@ module Kitchen
138
163
  File.join(config[:nodes_path], "#{instance.name}.json")
139
164
  end
140
165
 
141
- def int_node_file
166
+ def unix_int_node_file
142
167
  File.join(config[:root_path], 'nodes', "#{instance.name}.json")
143
168
  end
169
+
170
+ def win_int_node_file
171
+ File.join(config[:root_path], 'nodes', "#{instance.name}.json").tr('/', '\\')
172
+ end
144
173
  end
145
174
  end
146
175
  end
@@ -19,6 +19,6 @@
19
19
  module Kitchen
20
20
  # Version string for Policyfile_nodes Kitchen driver
21
21
  module Provisioner
22
- POLICYFILE_NODES_VERSION = '1.1.0'.freeze
22
+ POLICYFILE_NODES_VERSION = '1.2.0'.freeze
23
23
  end
24
24
  end
@@ -1,21 +1,7 @@
1
- # Policyfile_base - Base file to be evaluated by other Policyfiles
2
- # Don't use it as a standalone Policyfile, it doesn't work.
3
- #
4
- # For more information on the Policyfile feature, visit
5
- # https://github.com/opscode/chef-dk/blob/master/POLICYFILE_README.md
6
-
7
- # A name that describes what the system you're building with Chef does.
8
1
  name 'test'
9
-
10
- # Where to find external cookbooks:
11
2
  default_source :supermarket
12
-
13
- # Specify a custom source for a single cookbook:
14
3
  cookbook 'test', path: './'
15
-
16
- # run_list: chef-client will run these recipes in the order specified.
17
4
  run_list 'test::default'
18
-
19
- # named_run_lists
20
5
  named_run_list 'sftp', 'test::default'
6
+ named_run_list 'win', 'test::default'
21
7
  named_run_list 'ssh', 'test::search'
@@ -16,11 +16,18 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- first_node = search(:node, "name:sftp-* AND platform:#{node['platform']}")
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
20
26
 
21
- ruby_block 'save attributes' do
27
+ win_node = search(:node, 'platform:windows')
28
+ ruby_block 'save win attributes' do
22
29
  block do
23
30
  parent = File.join(ENV['TEMP'] || '/tmp', 'kitchen')
24
- IO.write(File.join(parent, 'sftp.json'), first_node[0].to_json)
31
+ IO.write(File.join(parent, 'win.json'), win_node[0].to_json)
25
32
  end
26
33
  end
@@ -9,38 +9,28 @@ describe 'sftp node' do
9
9
  IO.read(File.join(ENV['TEMP'] || '/tmp', 'kitchen/sftp.json'))
10
10
  )
11
11
  end
12
- let(:ip) { node['automatic']['ipaddress'] }
13
- let(:fqdn) { node['automatic']['fqdn'] }
14
- let(:connection) do
15
- Net::SSH.start(
16
- ip,
17
- 'vagrant',
18
- password: 'vagrant',
19
- paranoid: false
20
- )
12
+
13
+ it 'has ip' do
14
+ expect(node['automatic'].key?('ipaddress')).to eq(true)
21
15
  end
22
16
 
23
- it 'has an non localhost ip' do
24
- expect(ip).not_to eq('127.0.0.1')
17
+ it 'has fqdn' do
18
+ expect(node['automatic'].key?('fqdn')).to eq(true)
25
19
  end
20
+ end
26
21
 
27
- it 'has a valid ip' do
28
- expect(ip).to match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)
22
+ describe 'win node' do
23
+ let(:node) do
24
+ JSON.parse(
25
+ IO.read(File.join(ENV['TEMP'] || '/tmp', 'kitchen/win.json'))
26
+ )
29
27
  end
30
28
 
31
- describe command('hostname') do
32
- its(:stdout) { should_not match(/#{Regexp.quote(fqdn)}/) }
29
+ it 'has ip' do
30
+ expect(node['automatic'].key?('ipaddress')).to eq(true)
33
31
  end
34
32
 
35
- it 'has a computername matching node fqdn' do
36
- connection.open_channel do |channel|
37
- channel.request_pty
38
- channel.exec('hostname') do |_ch, _success|
39
- channel.on_data do |_ch, data|
40
- expect(data.chomp).to eq(fqdn)
41
- end
42
- end
43
- end
44
- connection.loop
33
+ it 'has fqdn' do
34
+ expect(node['automatic'].key?('fqdn')).to eq(true)
45
35
  end
46
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-policyfile-nodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Skopenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: 1.7.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: 1.7.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-dk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.10'
33
+ version: '0.12'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.10'
40
+ version: '0.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.5.2
146
+ rubygems_version: 2.6.4
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Test Kitchen provisioner based on policyfile_zero that generates searchable