kitchen-policyfile-nodes 1.0.1 → 1.1.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/CHANGELOG.md +9 -0
- data/README.md +2 -4
- data/lib/kitchen/provisioner/policyfile_nodes.rb +20 -88
- data/lib/kitchen/provisioner/policyfile_nodes_version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd3001fe7b97d7e286bf216736e46e7a2e154e26
|
|
4
|
+
data.tar.gz: 0ad6b3d0d2f563dbdb9843479ff72db3703f0b36
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92a9977dc49c2c681293a0fbff203d5ace3cc9c9f62d5051d01e31e2713d3f01f34e31f30ff7414501ddd9f2da42ea64123013b0c8fbfa17285b28740872aecb
|
|
7
|
+
data.tar.gz: a752e3cf02a01bacc1db2423db52b94758677b56b1750bfd76f88f73abb432bebef11a7c93d2bbf05c171b24d35b503b0f89b5e4749c1421e63fdf7cc1e94c83
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## 1.1.0 (March 16, 2015)
|
|
2
|
+
- Switch to SCP download of node json object
|
|
3
|
+
- Create node_path directory if doesn't exists
|
|
4
|
+
|
|
5
|
+
## 1.0.1 (March 15, 2015)
|
|
6
|
+
- Update documentation and gem description
|
|
7
|
+
|
|
8
|
+
## 1.0.0 (March 14, 2015)
|
|
9
|
+
- Initial release of kitchen-policyfile-nodes
|
data/README.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
# Kitchen::PolicyfileNodes
|
|
2
2
|
|
|
3
|
-
Provisioner `policyfile_nodes` extends `policyfile_zero` by adding one more step in the end of converge - it
|
|
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
|
|
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
5
|
Test Kitchen suites. So, you can use actual node IP addresses 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
|
-
`policyfile_nodes` supports SSH and SFTP (kitchen-sync) transporters.
|
|
11
|
-
|
|
12
10
|
## Requirements
|
|
13
11
|
|
|
14
12
|
* ChefDK 0.10.0+
|
|
@@ -49,103 +49,37 @@ module Kitchen
|
|
|
49
49
|
debug('Transfer complete')
|
|
50
50
|
conn.execute(env_cmd(provisioner.prepare_command))
|
|
51
51
|
conn.execute(env_cmd(provisioner.run_command))
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
# Download node json object generated by chef_client
|
|
53
|
+
info("Transferring #{provisioner.int_node_file} " \
|
|
54
|
+
"from instance to #{provisioner.ext_node_file}")
|
|
55
|
+
conn.execute(env_cmd(conn.download(provisioner.int_node_file,
|
|
56
|
+
provisioner.ext_node_file)))
|
|
57
|
+
debug('Transfer complete')
|
|
55
58
|
end
|
|
56
59
|
rescue Kitchen::Transport::TransportFailed => ex
|
|
57
60
|
raise ActionFailed, ex.message
|
|
58
61
|
ensure
|
|
59
62
|
instance.provisioner.cleanup_sandbox
|
|
60
63
|
end
|
|
61
|
-
|
|
62
|
-
def int_node_file
|
|
63
|
-
File.join(config[:root_path], 'nodes', "#{instance.name}.json")
|
|
64
|
-
end
|
|
65
64
|
end
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
|
|
69
68
|
module Kitchen
|
|
70
69
|
module Transport
|
|
71
|
-
class Sftp
|
|
72
|
-
class Connection
|
|
73
|
-
# Execute a remote command over SFTP and return the command's exit code and output.
|
|
74
|
-
#
|
|
75
|
-
# @param command [String] command string to execute
|
|
76
|
-
# @return [Hash] the exit code and output of the command
|
|
77
|
-
def execute_with_output_and_exit_code(command)
|
|
78
|
-
exit_code = nil
|
|
79
|
-
output = ''
|
|
80
|
-
session.open_channel do |channel|
|
|
81
|
-
channel.request_pty
|
|
82
|
-
|
|
83
|
-
channel.exec(command) do |_ch, _success|
|
|
84
|
-
channel.on_data do |_ch, data|
|
|
85
|
-
output << data
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
channel.on_extended_data do |_ch, _type, data|
|
|
89
|
-
output << data
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
channel.on_request('exit-status') do |_ch, data|
|
|
93
|
-
exit_code = data.read_long
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
session.loop { exit_code.nil? }
|
|
98
|
-
[exit_code, output]
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
70
|
class Ssh
|
|
104
71
|
class Connection
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
# @param command [String] command string to execute
|
|
108
|
-
# @return [Hash] the exit code and output of the command
|
|
109
|
-
def execute_with_output_and_exit_code(command)
|
|
110
|
-
exit_code = nil
|
|
111
|
-
output = ''
|
|
112
|
-
session.open_channel do |channel|
|
|
113
|
-
channel.request_pty
|
|
114
|
-
|
|
115
|
-
channel.exec(command) do |_ch, _success|
|
|
116
|
-
channel.on_data do |_ch, data|
|
|
117
|
-
output << data
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
channel.on_extended_data do |_ch, _type, data|
|
|
121
|
-
output << data
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
channel.on_request('exit-status') do |_ch, data|
|
|
125
|
-
exit_code = data.read_long
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
session.loop { exit_code.nil? }
|
|
130
|
-
[exit_code, output]
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# Execute command over SSH and return the command's output.
|
|
72
|
+
# Download JSON node file from instance to
|
|
73
|
+
# node_path over SCP
|
|
134
74
|
#
|
|
135
|
-
# @param
|
|
136
|
-
# @
|
|
137
|
-
def
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if exit_code != 0
|
|
143
|
-
raise Transport::SshFailed,
|
|
144
|
-
"SSH exited (#{exit_code}) for command: [#{command}]"
|
|
145
|
-
end
|
|
146
|
-
output
|
|
75
|
+
# @param remote [String] file path on instance
|
|
76
|
+
# @param local [String] file path on host
|
|
77
|
+
def download(remote, local)
|
|
78
|
+
FileUtils.mkdir_p(File.dirname(local))
|
|
79
|
+
session.scp.download!(remote, local, {})
|
|
80
|
+
logger.debug("Downloaded #{remote} to #{local}")
|
|
147
81
|
rescue Net::SSH::Exception => ex
|
|
148
|
-
raise SshFailed, "
|
|
82
|
+
raise SshFailed, "SCP download failed (#{ex.message})"
|
|
149
83
|
end
|
|
150
84
|
end
|
|
151
85
|
end
|
|
@@ -173,9 +107,11 @@ module Kitchen
|
|
|
173
107
|
debug('Transfer complete')
|
|
174
108
|
conn.execute(prepare_command)
|
|
175
109
|
conn.execute(run_command)
|
|
176
|
-
#
|
|
177
|
-
|
|
178
|
-
|
|
110
|
+
# Download node json object generated by chef_client
|
|
111
|
+
info("Transferring #{int_node_file} " \
|
|
112
|
+
"from instance to #{ext_node_file}")
|
|
113
|
+
conn.download(int_node_file, ext_node_file)
|
|
114
|
+
debug('Transfer complete')
|
|
179
115
|
end
|
|
180
116
|
rescue Kitchen::Transport::TransportFailed => ex
|
|
181
117
|
raise ActionFailed, ex.message
|
|
@@ -205,10 +141,6 @@ module Kitchen
|
|
|
205
141
|
def int_node_file
|
|
206
142
|
File.join(config[:root_path], 'nodes', "#{instance.name}.json")
|
|
207
143
|
end
|
|
208
|
-
|
|
209
|
-
def dump_command
|
|
210
|
-
"sh -c 'cat #{int_node_file}'"
|
|
211
|
-
end
|
|
212
144
|
end
|
|
213
145
|
end
|
|
214
146
|
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.0
|
|
4
|
+
version: 1.1.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-
|
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -111,6 +111,7 @@ files:
|
|
|
111
111
|
- ".gitignore"
|
|
112
112
|
- ".kitchen.yml"
|
|
113
113
|
- ".rubocop.yml"
|
|
114
|
+
- CHANGELOG.md
|
|
114
115
|
- Gemfile
|
|
115
116
|
- README.md
|
|
116
117
|
- Rakefile
|