hybrid_platforms_conductor 32.13.3 → 32.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/bin/get_impacted_nodes +1 -1
- data/bin/setup +6 -1
- data/docs/plugins.md +1 -0
- data/docs/plugins/platform_handler/serverless_chef.md +111 -0
- data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -1
- data/lib/hybrid_platforms_conductor/connector.rb +4 -2
- data/lib/hybrid_platforms_conductor/deployer.rb +2 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +535 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +51 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +232 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +1 -0
- data/lib/hybrid_platforms_conductor/nodes_handler.rb +9 -5
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +7 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +23 -0
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +11 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +17 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +94 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +317 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +65 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +292 -0
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +272 -0
- data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +53 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +14 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/policyfiles/test_policy.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/data_bags/my_bag/my_item.json +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +14 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/policyfiles/test_policy.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/hpc_test/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/hpc_test/cookbooks/hpc_test/recipes/after_run.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/hpc_test/cookbooks/hpc_test/recipes/before_run.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/hpc_test/nodes/node.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/hpc_test/policyfiles/test_policy.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_1/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/recipes/other_recipe.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/resources/my_resource.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node1.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/nodes/node2.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_1.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/policyfiles/test_policy_2.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/config.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/cookbooks/test_cookbook_1/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/nodes/node1.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/nodes/node2.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/recipes/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/recipes/other_recipe.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/resources/my_resource.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/policyfiles/test_policy_1.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/policyfiles/test_policy_2.rb +4 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/chef_versions.yml +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/nodes/local.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/nodes/node1.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/nodes/node2.json +10 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/policyfiles/test_policy_1.rb +3 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_nodes/policyfiles/test_policy_2.rb +3 -0
- metadata +192 -143
@@ -0,0 +1,272 @@
|
|
1
|
+
describe HybridPlatformsConductor::HpcPlugins::PlatformHandler::ServerlessChef do
|
2
|
+
|
3
|
+
context 'checking services deployment' do
|
4
|
+
|
5
|
+
# Simulate a packaging of a given repository
|
6
|
+
#
|
7
|
+
# Parameters::
|
8
|
+
# * *repository* (String): The repository we package
|
9
|
+
# * *service* (String): The service being packaged in this repository [default: 'test_policy']
|
10
|
+
def mock_package(repository, service: 'test_policy')
|
11
|
+
FileUtils.mkdir_p "#{repository}/dist/prod/#{service}"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get expected actions to deploy a service on a given node
|
15
|
+
#
|
16
|
+
# Parameters::
|
17
|
+
# * *repository* (String): Platform repository
|
18
|
+
# * *check_mode* (Boolean): Are we expected check-mode? [default: false]
|
19
|
+
# * *sudo* (String): sudo prefix command [default: 'sudo -u root ']
|
20
|
+
# * *env* (String): Environment expected to be packaged [default: 'prod']
|
21
|
+
# * *policy* (String): Expected policy to be packaged [default: 'test_policy']
|
22
|
+
# * *node* (String): Expected node to be deployed [default: 'node']
|
23
|
+
# Result::
|
24
|
+
# * Array: Expected actions
|
25
|
+
def expected_actions_to_deploy_chef(
|
26
|
+
repository,
|
27
|
+
check_mode: false,
|
28
|
+
sudo: 'sudo -u root ',
|
29
|
+
env: 'prod',
|
30
|
+
policy: 'test_policy',
|
31
|
+
node: 'node'
|
32
|
+
)
|
33
|
+
[
|
34
|
+
{
|
35
|
+
remote_bash: [
|
36
|
+
'set -e',
|
37
|
+
'set -o pipefail',
|
38
|
+
"if [ -n \"$(command -v apt)\" ]; then #{sudo}apt update && #{sudo}apt install -y curl build-essential ; else #{sudo}yum groupinstall 'Development Tools' && #{sudo}yum install -y curl ; fi",
|
39
|
+
'mkdir -p ./hpc_deploy',
|
40
|
+
'rm -rf ./hpc_deploy/tmp',
|
41
|
+
'mkdir -p ./hpc_deploy/tmp',
|
42
|
+
'curl --location https://omnitruck.chef.io/install.sh --output ./hpc_deploy/install.sh',
|
43
|
+
'chmod a+x ./hpc_deploy/install.sh',
|
44
|
+
"#{sudo}TMPDIR=./hpc_deploy/tmp ./hpc_deploy/install.sh -d /opt/artefacts -v 17.0 -s once"
|
45
|
+
]
|
46
|
+
},
|
47
|
+
{
|
48
|
+
scp: { "#{repository}/dist/#{env}/#{policy}" => './hpc_deploy' },
|
49
|
+
remote_bash: [
|
50
|
+
'set -e',
|
51
|
+
"cd ./hpc_deploy/#{policy}",
|
52
|
+
"#{sudo}SSL_CERT_DIR=/etc/ssl/certs /opt/chef/bin/chef-client --local-mode --chef-license accept --json-attributes nodes/#{node}.json#{check_mode ? ' --why-run' : ''}",
|
53
|
+
'cd ..',
|
54
|
+
"#{sudo}rm -rf ./hpc_deploy/#{policy}"
|
55
|
+
]
|
56
|
+
}
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with an empty platform' do
|
61
|
+
|
62
|
+
it 'prepares for deploy' do
|
63
|
+
with_serverless_chef_platforms('empty') do |platform, repository|
|
64
|
+
platform.prepare_for_deploy(
|
65
|
+
services: {},
|
66
|
+
secrets: {},
|
67
|
+
local_environment: false,
|
68
|
+
why_run: false
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'prepares for deploy in why-run mode' do
|
74
|
+
with_serverless_chef_platforms('empty') do |platform, repository|
|
75
|
+
platform.prepare_for_deploy(
|
76
|
+
services: {},
|
77
|
+
secrets: {},
|
78
|
+
local_environment: false,
|
79
|
+
why_run: true
|
80
|
+
)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'prepares for deploy in local mode' do
|
85
|
+
with_serverless_chef_platforms('empty') do |platform, repository|
|
86
|
+
platform.prepare_for_deploy(
|
87
|
+
services: {},
|
88
|
+
secrets: {},
|
89
|
+
local_environment: true,
|
90
|
+
why_run: false
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'with a platform having 1 node' do
|
98
|
+
|
99
|
+
it 'returns actions to deploy on this node' do
|
100
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
101
|
+
mock_package(repository)
|
102
|
+
platform.prepare_for_deploy(
|
103
|
+
services: { 'node' => %w[test_policy] },
|
104
|
+
secrets: {},
|
105
|
+
local_environment: false,
|
106
|
+
why_run: false
|
107
|
+
)
|
108
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'returns actions to deploy on this node with node attributes setup from metadata' do
|
113
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
114
|
+
test_nodes_handler.override_metadata_of 'node', :new_metadata, 'new_value'
|
115
|
+
mock_package(repository)
|
116
|
+
platform.prepare_for_deploy(
|
117
|
+
services: { 'node' => %w[test_policy] },
|
118
|
+
secrets: {},
|
119
|
+
local_environment: false,
|
120
|
+
why_run: false
|
121
|
+
)
|
122
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository)
|
123
|
+
attributes_file = "#{repository}/dist/prod/test_policy/nodes/node.json"
|
124
|
+
expect(File.exist?(attributes_file)).to eq true
|
125
|
+
expect(JSON.parse(File.read(attributes_file))).to eq(
|
126
|
+
'description' => 'Single test node',
|
127
|
+
'image' => 'debian_9',
|
128
|
+
'new_metadata' => 'new_value',
|
129
|
+
'private_ips' => ['172.16.0.1'],
|
130
|
+
'property1' => { 'property11' => 'value11' },
|
131
|
+
'property2' => 'value2',
|
132
|
+
)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'returns actions to deploy on this node with secrets' do
|
137
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
138
|
+
mock_package(repository)
|
139
|
+
platform.prepare_for_deploy(
|
140
|
+
services: { 'node' => %w[test_policy] },
|
141
|
+
secrets: { 'my_secret' => 'secret_value' },
|
142
|
+
local_environment: false,
|
143
|
+
why_run: false
|
144
|
+
)
|
145
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns actions to deploy on this node in why-run mode' do
|
150
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
151
|
+
mock_package(repository)
|
152
|
+
platform.prepare_for_deploy(
|
153
|
+
services: { 'node' => %w[test_policy] },
|
154
|
+
secrets: {},
|
155
|
+
local_environment: false,
|
156
|
+
why_run: true
|
157
|
+
)
|
158
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: true)).to eq expected_actions_to_deploy_chef(repository, check_mode: true)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'returns actions to deploy on this node using local mode' do
|
163
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
164
|
+
mock_package(repository)
|
165
|
+
platform.prepare_for_deploy(
|
166
|
+
services: { 'node' => %w[test_policy] },
|
167
|
+
secrets: {},
|
168
|
+
local_environment: true,
|
169
|
+
why_run: false
|
170
|
+
)
|
171
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository, env: 'local')
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'returns actions to deploy on this node in why-run mode and local mode' do
|
176
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
177
|
+
mock_package(repository)
|
178
|
+
platform.prepare_for_deploy(
|
179
|
+
services: { 'node' => %w[test_policy] },
|
180
|
+
secrets: {},
|
181
|
+
local_environment: true,
|
182
|
+
why_run: true
|
183
|
+
)
|
184
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: true)).to eq expected_actions_to_deploy_chef(repository, env: 'local', check_mode: true)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'returns actions to deploy on this node using root user' do
|
189
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
190
|
+
test_actions_executor.connector(:ssh).ssh_user = 'root'
|
191
|
+
mock_package(repository)
|
192
|
+
platform.prepare_for_deploy(
|
193
|
+
services: { 'node' => %w[test_policy] },
|
194
|
+
secrets: {},
|
195
|
+
local_environment: false,
|
196
|
+
why_run: false
|
197
|
+
)
|
198
|
+
expect(platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository, sudo: '')
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'fails with a nice message when chef_versions.yml is missing' do
|
203
|
+
with_serverless_chef_platforms('1_node') do |platform, repository|
|
204
|
+
mock_package(repository)
|
205
|
+
platform.prepare_for_deploy(
|
206
|
+
services: { 'node' => %w[test_policy] },
|
207
|
+
secrets: {},
|
208
|
+
local_environment: false,
|
209
|
+
why_run: false
|
210
|
+
)
|
211
|
+
File.unlink("#{repository}/chef_versions.yml")
|
212
|
+
expect { platform.actions_to_deploy_on('node', 'test_policy', use_why_run: false) }.to raise_error "Missing file #{repository}/chef_versions.yml specifying the Chef Infra Client version to be deployed"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'with a platform having several nodes' do
|
219
|
+
|
220
|
+
it 'deploys services declared on 1 node on another node if asked' do
|
221
|
+
with_serverless_chef_platforms('several_nodes') do |platform, repository|
|
222
|
+
mock_package(repository)
|
223
|
+
platform.prepare_for_deploy(
|
224
|
+
services: { 'node2' => %w[test_policy_1] },
|
225
|
+
secrets: {},
|
226
|
+
local_environment: false,
|
227
|
+
why_run: false
|
228
|
+
)
|
229
|
+
expect(platform.actions_to_deploy_on('node2', 'test_policy_1', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository, policy: 'test_policy_1', node: 'node2')
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'deploys local nodes' do
|
234
|
+
with_serverless_chef_platforms('several_nodes') do |platform, repository|
|
235
|
+
mock_package(repository)
|
236
|
+
platform.prepare_for_deploy(
|
237
|
+
services: { 'local' => %w[test_policy_1] },
|
238
|
+
secrets: {},
|
239
|
+
local_environment: false,
|
240
|
+
why_run: false
|
241
|
+
)
|
242
|
+
expect(platform.actions_to_deploy_on('local', 'test_policy_1', use_why_run: false)).to eq [
|
243
|
+
{
|
244
|
+
bash: "cd #{repository}/dist/prod/test_policy_1 && sudo SSL_CERT_DIR=/etc/ssl/certs /opt/chef-workstation/bin/chef-client --local-mode --chef-license accept --json-attributes nodes/local.json"
|
245
|
+
}
|
246
|
+
]
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
context 'with 2 platforms' do
|
253
|
+
|
254
|
+
it 'deploys a service on a node belonging to another platform' do
|
255
|
+
with_serverless_chef_platforms({ 'p1' => '1_node', 'p2' => 'several_nodes' }) do |repositories|
|
256
|
+
platform_p1, repository_p1 = repositories.find { |platform, _repository| platform.name == 'p1' }
|
257
|
+
mock_package(repository_p1)
|
258
|
+
platform_p1.prepare_for_deploy(
|
259
|
+
services: { 'node2' => %w[test_policy_1] },
|
260
|
+
secrets: {},
|
261
|
+
local_environment: false,
|
262
|
+
why_run: false
|
263
|
+
)
|
264
|
+
expect(platform_p1.actions_to_deploy_on('node2', 'test_policy_1', use_why_run: false)).to eq expected_actions_to_deploy_chef(repository_p1, policy: 'test_policy_1', node: 'node2')
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
end
|
@@ -31,7 +31,7 @@ module HybridPlatformsConductorTest
|
|
31
31
|
end
|
32
32
|
# We need to protect the access to this array as the mocked commands can be called by competing threads
|
33
33
|
remaining_expected_commands_mutex = Mutex.new
|
34
|
-
allow(cmd_runner).to receive(:run_cmd) do |cmd, log_to_file: nil, log_to_stdout: true, log_stdout_to_io: nil, log_stderr_to_io: nil, expected_code: 0, timeout: nil, no_exception: false|
|
34
|
+
allow(cmd_runner).to receive(:run_cmd) do |cmd, log_to_file: nil, log_to_stdout: true, log_stdout_to_io: nil, log_stderr_to_io: nil, expected_code: 0, timeout: nil, no_exception: false, force_bash: false|
|
35
35
|
# Check the remaining expected commands
|
36
36
|
found_command = nil
|
37
37
|
found_command_code = nil
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef'
|
2
|
+
|
3
|
+
module HybridPlatformsConductorTest
|
4
|
+
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
module ServerlessChefHelpers
|
8
|
+
|
9
|
+
# Setup a platforms config using test repository names
|
10
|
+
#
|
11
|
+
# Parameters::
|
12
|
+
# * *names* (String or Hash<String, String>): The test repository name (taken from the repositories/ folder), or a Hash of names and their corresponding test repository source name
|
13
|
+
# * *additional_config* (String): Additional config to append after the platform declaration [default: '']
|
14
|
+
# * *as_git* (Boolean): Should we initialize the repository as a git repo? [default: false]
|
15
|
+
# * Proc: Code called when repository is setup
|
16
|
+
# * Parameters::
|
17
|
+
# If there was only 1 repository:
|
18
|
+
# * *platform* (PlatformHandler): The platform handler to be tested
|
19
|
+
# * *repository* (String): Repository path
|
20
|
+
# If there was multiple repositories:
|
21
|
+
# * *repositories* (Hash<PlatformHandler,String>): Set of repositories, per platform handler
|
22
|
+
def with_serverless_chef_platforms(names, additional_config: '', as_git: false)
|
23
|
+
names = { names => names } unless names.is_a?(Hash)
|
24
|
+
with_repositories(names.keys, as_git: as_git) do |repositories|
|
25
|
+
repositories.each do |name, repository|
|
26
|
+
# Copy the content of the test repository in the temporary one
|
27
|
+
FileUtils.cp_r "#{__dir__}/../serverless_chef_repositories/#{names[name]}/.", repository
|
28
|
+
end
|
29
|
+
with_platforms(repositories.values.map { |repository| "serverless_chef_platform path: '#{repository}'\n" }.join + additional_config) do
|
30
|
+
repositories = Hash[names.keys.map do |name|
|
31
|
+
[
|
32
|
+
test_platforms_handler.platform(name),
|
33
|
+
repositories[name]
|
34
|
+
]
|
35
|
+
end]
|
36
|
+
test_platforms_handler.inject_dependencies(
|
37
|
+
nodes_handler: test_nodes_handler,
|
38
|
+
actions_executor: test_actions_executor
|
39
|
+
)
|
40
|
+
if repositories.size == 1
|
41
|
+
yield *repositories.first
|
42
|
+
else
|
43
|
+
yield repositories
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "node",
|
3
|
+
"normal": {
|
4
|
+
"description": "Single test node",
|
5
|
+
"image": "debian_9",
|
6
|
+
"private_ips": ["172.16.0.1"],
|
7
|
+
"property1": {
|
8
|
+
"property11": "value11"
|
9
|
+
},
|
10
|
+
"property2": "value2"
|
11
|
+
},
|
12
|
+
"policy_name": "test_policy",
|
13
|
+
"policy_group": "test_group"
|
14
|
+
}
|
data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"name": "node",
|
3
|
+
"normal": {
|
4
|
+
"description": "Single test node",
|
5
|
+
"image": "debian_9",
|
6
|
+
"private_ips": ["172.16.0.1"],
|
7
|
+
"property1": {
|
8
|
+
"property11": "value11"
|
9
|
+
},
|
10
|
+
"property2": "value2"
|
11
|
+
},
|
12
|
+
"policy_name": "test_policy",
|
13
|
+
"policy_group": "test_group"
|
14
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
# Recipe
|
@@ -0,0 +1 @@
|
|
1
|
+
# Recipe
|
@@ -0,0 +1 @@
|
|
1
|
+
# Default recipe
|
@@ -0,0 +1 @@
|
|
1
|
+
# Recipe code
|
@@ -0,0 +1 @@
|
|
1
|
+
# Recipe code
|
@@ -0,0 +1 @@
|
|
1
|
+
# Resource code
|