hybrid_platforms_conductor 33.3.0 → 33.7.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +31 -2
  4. data/docs/config_dsl.md +45 -0
  5. data/docs/plugins/cmdb/host_keys.md +3 -1
  6. data/docs/plugins/connector/ssh.md +1 -0
  7. data/lib/hybrid_platforms_conductor/actions_executor.rb +29 -1
  8. data/lib/hybrid_platforms_conductor/bitbucket.rb +134 -90
  9. data/lib/hybrid_platforms_conductor/cmd_runner.rb +4 -4
  10. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +12 -44
  11. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +9 -31
  12. data/lib/hybrid_platforms_conductor/config.rb +2 -0
  13. data/lib/hybrid_platforms_conductor/confluence.rb +93 -88
  14. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  15. data/lib/hybrid_platforms_conductor/credentials.rb +122 -97
  16. data/lib/hybrid_platforms_conductor/deployer.rb +7 -9
  17. data/lib/hybrid_platforms_conductor/github.rb +39 -0
  18. data/lib/hybrid_platforms_conductor/hpc_plugins/action/bash.rb +1 -1
  19. data/lib/hybrid_platforms_conductor/hpc_plugins/action/remote_bash.rb +27 -17
  20. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +13 -12
  21. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +6 -4
  22. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/my_connector.rb.sample +1 -1
  23. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +37 -25
  24. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +5 -6
  25. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +1 -1
  26. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +1 -1
  27. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +7 -4
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +3 -1
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +3 -2
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +3 -1
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +4 -1
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +17 -3
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +30 -10
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +1 -1
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +4 -1
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +1 -2
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +1 -1
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -2
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +7 -3
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +8 -4
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +1 -2
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +1 -2
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +1 -2
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +1 -1
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +1 -2
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +3 -1
  47. data/lib/hybrid_platforms_conductor/logger_helpers.rb +24 -1
  48. data/lib/hybrid_platforms_conductor/test.rb +21 -7
  49. data/lib/hybrid_platforms_conductor/tests_runner.rb +7 -6
  50. data/lib/hybrid_platforms_conductor/thycotic.rb +80 -75
  51. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  52. data/spec/hybrid_platforms_conductor_test.rb +6 -0
  53. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +15 -0
  54. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +32 -0
  55. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +87 -0
  56. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +30 -0
  57. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +10 -0
  58. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +38 -0
  59. data/spec/hybrid_platforms_conductor_test/api/actions_executor/helpers_spec.rb +195 -0
  60. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +14 -0
  61. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +11 -0
  62. data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +251 -0
  63. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +215 -0
  64. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +280 -319
  65. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +2 -2
  66. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +49 -10
  67. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +38 -0
  68. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +49 -69
  69. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +29 -39
  70. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +5 -3
  71. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_local_node/chef_versions.yml +3 -0
  72. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_local_node/nodes/node.json +15 -0
  73. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_local_node/policyfiles/test_policy.rb +3 -0
  74. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +134 -0
  75. data/spec/hybrid_platforms_conductor_test/test_connector.rb +2 -2
  76. metadata +36 -2
@@ -0,0 +1,3 @@
1
+ name File.basename(__FILE__, '.rb')
2
+ default_source :supermarket
3
+ run_list 'recipe[test_cookbook]'
@@ -46,6 +46,30 @@ shared_examples 'a deployer' do
46
46
  end
47
47
  end
48
48
 
49
+ it 'deploys on 1 local node' do
50
+ with_platform_to_deploy(nodes_info: { nodes: { 'node' => { meta: { local_node: true }, services: %w[service] } } }) do
51
+ # Make sure the ssh_user is ignored in this case
52
+ test_actions_executor.connector(:ssh).ssh_user = 'root'
53
+ with_cmd_runner_mocked [
54
+ ['whoami', proc { [0, 'test_user', ''] }]
55
+ ] do
56
+ expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
57
+ end
58
+ end
59
+ end
60
+
61
+ it 'deploys on 1 local node as root' do
62
+ with_platform_to_deploy(nodes_info: { nodes: { 'node' => { meta: { local_node: true }, services: %w[service] } } }, expect_sudo: nil) do
63
+ # Make sure the ssh_user is ignored in this case
64
+ test_actions_executor.connector(:ssh).ssh_user = 'test_user'
65
+ with_cmd_runner_mocked [
66
+ ['whoami', proc { [0, 'root', ''] }]
67
+ ] do
68
+ expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
69
+ end
70
+ end
71
+ end
72
+
49
73
  it 'deploys on 1 node using 1 secret' do
50
74
  with_platform_to_deploy(expect_secrets: { 'secret1' => 'password1' }) do
51
75
  test_deployer.override_secrets('secret1' => 'password1')
@@ -137,6 +161,61 @@ shared_examples 'a deployer' do
137
161
  end
138
162
  end
139
163
 
164
+ it 'deploys on 1 local node in local environment with certificates to install using hpc_certificates on Debian' do
165
+ with_certs_dir do |certs_dir|
166
+ with_platform_to_deploy(
167
+ nodes_info: { nodes: { 'node' => { meta: { local_node: true, image: 'debian_9' }, services: %w[service] } } },
168
+ expect_local_environment: true,
169
+ expect_additional_actions: [
170
+ { remote_bash: 'sudo -u root apt update && sudo -u root apt install -y ca-certificates' },
171
+ {
172
+ remote_bash: 'sudo -u root update-ca-certificates',
173
+ scp: {
174
+ certs_dir => '/usr/local/share/ca-certificates',
175
+ :sudo => true
176
+ }
177
+ }
178
+ ]
179
+ ) do
180
+ ENV['hpc_certificates'] = certs_dir
181
+ test_deployer.local_environment = true
182
+ with_cmd_runner_mocked [
183
+ ['whoami', proc { [0, 'test_user', ''] }]
184
+ ] do
185
+ expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
186
+ end
187
+ end
188
+ end
189
+ end
190
+
191
+ it 'deploys on 1 local node in local environment with certificates to install using hpc_certificates on Debian as root' do
192
+ with_certs_dir do |certs_dir|
193
+ with_platform_to_deploy(
194
+ nodes_info: { nodes: { 'node' => { meta: { local_node: true, image: 'debian_9' }, services: %w[service] } } },
195
+ expect_sudo: nil,
196
+ expect_local_environment: true,
197
+ expect_additional_actions: [
198
+ { remote_bash: 'apt update && apt install -y ca-certificates' },
199
+ {
200
+ remote_bash: 'update-ca-certificates',
201
+ scp: {
202
+ certs_dir => '/usr/local/share/ca-certificates',
203
+ :sudo => false
204
+ }
205
+ }
206
+ ]
207
+ ) do
208
+ ENV['hpc_certificates'] = certs_dir
209
+ test_deployer.local_environment = true
210
+ with_cmd_runner_mocked [
211
+ ['whoami', proc { [0, 'root', ''] }]
212
+ ] do
213
+ expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
214
+ end
215
+ end
216
+ end
217
+ end
218
+
140
219
  it 'deploys on 1 node with certificates to install using hpc_certificates on CentOS' do
141
220
  with_certs_dir do |certs_dir|
142
221
  with_platform_to_deploy(
@@ -212,6 +291,61 @@ shared_examples 'a deployer' do
212
291
  end
213
292
  end
214
293
 
294
+ it 'deploys on 1 local node with certificates to install using hpc_certificates on CentOS' do
295
+ with_certs_dir do |certs_dir|
296
+ with_platform_to_deploy(
297
+ nodes_info: { nodes: { 'node' => { meta: { local_node: true, image: 'centos_7' }, services: %w[service] } } },
298
+ expect_local_environment: true,
299
+ expect_additional_actions: [
300
+ { remote_bash: 'sudo -u root yum install -y ca-certificates' },
301
+ {
302
+ remote_bash: ['sudo -u root update-ca-trust enable', 'sudo -u root update-ca-trust extract'],
303
+ scp: {
304
+ "#{certs_dir}/test_cert.crt" => '/etc/pki/ca-trust/source/anchors',
305
+ :sudo => true
306
+ }
307
+ }
308
+ ]
309
+ ) do
310
+ ENV['hpc_certificates'] = certs_dir
311
+ test_deployer.local_environment = true
312
+ with_cmd_runner_mocked [
313
+ ['whoami', proc { [0, 'test_user', ''] }]
314
+ ] do
315
+ expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
316
+ end
317
+ end
318
+ end
319
+ end
320
+
321
+ it 'deploys on 1 local node with certificates to install using hpc_certificates on CentOS as root' do
322
+ with_certs_dir do |certs_dir|
323
+ with_platform_to_deploy(
324
+ nodes_info: { nodes: { 'node' => { meta: { local_node: true, image: 'centos_7' }, services: %w[service] } } },
325
+ expect_sudo: nil,
326
+ expect_local_environment: true,
327
+ expect_additional_actions: [
328
+ { remote_bash: 'yum install -y ca-certificates' },
329
+ {
330
+ remote_bash: ['update-ca-trust enable', 'update-ca-trust extract'],
331
+ scp: {
332
+ "#{certs_dir}/test_cert.crt" => '/etc/pki/ca-trust/source/anchors',
333
+ :sudo => false
334
+ }
335
+ }
336
+ ]
337
+ ) do
338
+ ENV['hpc_certificates'] = certs_dir
339
+ test_deployer.local_environment = true
340
+ with_cmd_runner_mocked [
341
+ ['whoami', proc { [0, 'root', ''] }]
342
+ ] do
343
+ expect(test_deployer.deploy_on('node')).to eq('node' => expected_deploy_result)
344
+ end
345
+ end
346
+ end
347
+ end
348
+
215
349
  it 'deploys on several nodes' do
216
350
  with_platform_to_deploy(
217
351
  nodes_info: {
@@ -100,9 +100,9 @@ module HybridPlatformsConductorTest
100
100
  # [API] - @stderr_io can be used to send stderr output
101
101
  #
102
102
  # Parameters::
103
- # * *bash_cmds* (String): Bash commands to execute
103
+ # * *bash_cmds* (String or SecretString): Bash commands to execute. Use #to_unprotected to access the real content (otherwise secrets are obfuscated).
104
104
  def remote_bash(bash_cmds)
105
- @calls << [:remote_bash, bash_cmds]
105
+ @calls << [:remote_bash, bash_cmds.to_unprotected.clone]
106
106
  @remote_bash_code&.call(@stdout_io, @stderr_io, self)
107
107
  end
108
108
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 33.3.0
4
+ version: 33.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
278
  version: '1.0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: secret_string
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '1.1'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '1.1'
279
293
  - !ruby/object:Gem::Dependency
280
294
  name: rspec
281
295
  requirement: !ruby/object:Gem::Requirement
@@ -332,6 +346,20 @@ dependencies:
332
346
  - - "~>"
333
347
  - !ruby/object:Gem::Version
334
348
  version: '2.4'
349
+ - !ruby/object:Gem::Dependency
350
+ name: webmock
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: '3.11'
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: '3.11'
335
363
  description: Provides a complete toolset to help DevOps maintain, deploy, monitor
336
364
  and test multiple platforms using various technologies
337
365
  email:
@@ -718,6 +746,7 @@ files:
718
746
  - lib/hybrid_platforms_conductor/current_dir_monitor.rb
719
747
  - lib/hybrid_platforms_conductor/deployer.rb
720
748
  - lib/hybrid_platforms_conductor/executable.rb
749
+ - lib/hybrid_platforms_conductor/github.rb
721
750
  - lib/hybrid_platforms_conductor/hpc_plugins/action/bash.rb
722
751
  - lib/hybrid_platforms_conductor/hpc_plugins/action/interactive.rb
723
752
  - lib/hybrid_platforms_conductor/hpc_plugins/action/my_action.rb.sample
@@ -837,11 +866,13 @@ files:
837
866
  - spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb
838
867
  - spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb
839
868
  - spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb
869
+ - spec/hybrid_platforms_conductor_test/api/actions_executor/helpers_spec.rb
840
870
  - spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb
841
871
  - spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb
842
872
  - spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb
843
873
  - spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb
844
874
  - spec/hybrid_platforms_conductor_test/api/config_spec.rb
875
+ - spec/hybrid_platforms_conductor_test/api/credentials_spec.rb
845
876
  - spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb
846
877
  - spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb
847
878
  - spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb
@@ -952,6 +983,9 @@ files:
952
983
  - spec/hybrid_platforms_conductor_test/platform_handler_plugins/test_2.rb
953
984
  - spec/hybrid_platforms_conductor_test/report_plugin.rb
954
985
  - spec/hybrid_platforms_conductor_test/rubocop_spec.rb
986
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_local_node/chef_versions.yml
987
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_local_node/nodes/node.json
988
+ - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_local_node/policyfiles/test_policy.rb
955
989
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/chef_versions.yml
956
990
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json
957
991
  - spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/policyfiles/test_policy.rb