hybrid_platforms_conductor 32.17.0 → 33.0.2

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 (283) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/README.md +6 -3
  4. data/bin/check-node +0 -1
  5. data/bin/deploy +0 -1
  6. data/bin/get_impacted_nodes +0 -1
  7. data/bin/last_deploys +12 -8
  8. data/bin/nodes_to_deploy +6 -6
  9. data/bin/setup +6 -6
  10. data/bin/topograph +1 -1
  11. data/docs/config_dsl.md +45 -1
  12. data/docs/executables.md +6 -7
  13. data/docs/executables/check-node.md +3 -3
  14. data/docs/executables/deploy.md +3 -3
  15. data/docs/executables/dump_nodes_json.md +3 -3
  16. data/docs/executables/test.md +3 -3
  17. data/docs/executables/topograph.md +3 -3
  18. data/docs/gen/mermaid/README.md-0.png +0 -0
  19. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  20. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  21. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  22. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  23. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  24. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  25. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  26. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  27. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  28. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  29. data/docs/plugins.md +46 -0
  30. data/docs/plugins/connector/ssh.md +1 -1
  31. data/docs/plugins/log/remote_fs.md +26 -0
  32. data/docs/plugins/secrets_reader/cli.md +31 -0
  33. data/docs/plugins/secrets_reader/thycotic.md +46 -0
  34. data/docs/plugins/test/check_deploy_and_idempotence.md +1 -1
  35. data/docs/plugins/test/connection.md +1 -0
  36. data/docs/plugins/test/deploy_removes_root_access.md +1 -1
  37. data/docs/plugins/test/file_system.md +1 -0
  38. data/docs/plugins/test/hostname.md +1 -0
  39. data/docs/plugins/test/ip.md +1 -0
  40. data/docs/plugins/test/local_users.md +1 -0
  41. data/docs/plugins/test/mounts.md +1 -0
  42. data/docs/plugins/test/orphan_files.md +1 -0
  43. data/docs/plugins/test/ports.md +1 -0
  44. data/docs/plugins/test/spectre.md +1 -0
  45. data/docs/plugins/test/vulnerabilities.md +1 -0
  46. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  47. data/lib/hybrid_platforms_conductor/actions_executor.rb +45 -43
  48. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  49. data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
  50. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  51. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  52. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  53. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  54. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  55. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  56. data/lib/hybrid_platforms_conductor/config.rb +8 -4
  57. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  58. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  59. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +116 -0
  60. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  61. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  62. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  63. data/lib/hybrid_platforms_conductor/deployer.rb +275 -224
  64. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample +100 -0
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +180 -0
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
  74. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  75. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  76. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  77. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  78. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  79. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
  80. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  81. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  82. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  83. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  84. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  85. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
  86. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
  87. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
  88. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  89. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  90. data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +3 -1
  91. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -21
  92. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  93. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  94. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  95. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +21 -22
  96. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  97. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  98. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +3 -1
  99. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  100. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +4 -2
  101. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  102. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  103. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  104. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +5 -3
  105. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +5 -3
  106. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +13 -10
  107. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +5 -3
  108. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  109. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  110. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +7 -7
  111. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  112. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +27 -25
  113. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  114. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  115. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  116. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  117. data/lib/hybrid_platforms_conductor/log.rb +31 -0
  118. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  119. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  120. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  121. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  122. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  123. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  124. data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
  125. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  126. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  127. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  128. data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
  129. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  130. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +18 -0
  131. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  132. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  133. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  134. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  135. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  136. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  137. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  138. data/spec/hybrid_platforms_conductor_test.rb +33 -12
  139. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +18 -11
  140. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +2 -2
  141. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +32 -21
  142. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +75 -49
  143. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +27 -15
  144. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +90 -59
  145. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +46 -44
  146. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  147. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  148. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  149. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  150. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  151. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +106 -75
  152. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  153. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  154. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  155. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +167 -142
  156. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  157. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +16 -16
  158. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
  159. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  160. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  161. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +43 -5
  162. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +199 -216
  163. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
  164. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  165. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  166. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  167. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  168. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  169. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  170. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  171. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  172. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  173. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  174. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  175. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  176. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  177. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  178. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  179. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  180. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  181. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
  182. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
  183. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  184. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  185. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  186. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  187. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  188. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  189. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  190. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  191. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  192. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  193. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  194. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  195. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  196. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  197. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  198. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  199. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  200. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  201. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  202. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  203. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  204. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  205. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  206. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  207. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  208. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  209. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  210. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  211. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +5 -4
  212. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  213. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  214. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  215. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  216. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  217. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  218. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  219. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  220. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  221. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  222. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  223. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  224. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  225. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  226. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  227. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  228. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +159 -113
  229. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +299 -160
  230. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  231. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  232. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -8
  233. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
  234. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  235. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  236. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  237. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  238. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  239. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  240. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  241. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  242. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  243. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  244. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  245. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  246. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  247. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +245 -56
  248. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  249. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  250. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  251. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  252. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  253. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  254. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  255. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  256. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  257. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id1.rb → test_plugin_id_1.rb} +0 -0
  258. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id2.rb → test_plugin_id_2.rb} +0 -0
  259. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/{test_plugin_id3.rb → test_plugin_id_3.rb} +0 -0
  260. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/{test_plugin_type2/test_plugin_id4.rb → test_plugin_type_2/test_plugin_id_4.rb} +0 -0
  261. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  262. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  263. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  264. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  265. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  266. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  267. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  268. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  269. data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
  270. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +84 -0
  271. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +105 -0
  272. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  273. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  274. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  275. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  276. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  277. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
  278. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  279. data/spec/spec_helper.rb +17 -18
  280. data/tools/check_md +16 -20
  281. data/tools/generate_mermaid +1 -1
  282. metadata +195 -144
  283. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -916
@@ -0,0 +1,100 @@
1
+ require 'hybrid_platforms_conductor/log'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module Log
8
+
9
+ # Save logs on the remote node's file system
10
+ class RemoteFs < HybridPlatformsConductor::Log
11
+
12
+ # Get actions to save logs
13
+ # [API] - This method is mandatory.
14
+ # [API] - The following API components are accessible:
15
+ # * *@config* (Config): Main configuration API.
16
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
17
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
18
+ #
19
+ # Parameters::
20
+ # * *node* (String): Node for which logs are being saved
21
+ # * *services* (Array<String>): The list of services that have been deployed on this node
22
+ # * *deployment_info* (Hash<Symbol,Object>): Additional information to attach to the logs
23
+ # * *exit_status* (Integer or Symbol): Exit status of the deployment
24
+ # * *stdout* (String): Deployment's stdout
25
+ # * *stderr* (String): Deployment's stderr
26
+ # Result::
27
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
28
+ def actions_to_save_logs(node, services, deployment_info, exit_status, stdout, stderr)
29
+ # Return here all actions that are to be run to save those logs.
30
+ [
31
+ {
32
+ bash: <<~EOS
33
+ cat <<'EOLOGFILE' >>all_logs.txt
34
+ Deployment log on #{node}:
35
+ #{stdout}
36
+ EOLOGFILE
37
+ EOS
38
+ }
39
+ ]
40
+ end
41
+
42
+ # Get actions to read logs.
43
+ # If provided, this method can return some actions to be executed that will fetch logs from servers or remote nodes.
44
+ # By using this method to run actions instead of the synchronous method logs_from, such actions will be run in parallel which can greatly improve time-consuming operations when querying a lot of nodes.
45
+ # [API] - This method is optional.
46
+ # [API] - The following API components are accessible:
47
+ # * *@config* (Config): Main configuration API.
48
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
49
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
50
+ #
51
+ # Parameters::
52
+ # * *node* (String): Node for which deployment logs are being read
53
+ # Result::
54
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
55
+ def actions_to_read_logs(node)
56
+ [
57
+ { bash: 'cat all_logs.txt' }
58
+ ]
59
+ end
60
+
61
+ # Get deployment logs from a node.
62
+ # This method can use the result of actions previously run to read logs, as returned by the actions_to_read_logs method.
63
+ # [API] - This method is mandatory.
64
+ # [API] - The following API components are accessible:
65
+ # * *@config* (Config): Main configuration API.
66
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
67
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
68
+ #
69
+ # Parameters::
70
+ # * *node* (String): The node we want deployment logs from
71
+ # * *exit_status* (Integer, Symbol or nil): Exit status of actions to read logs, or nil if no action was returned by actions_to_read_logs
72
+ # * *stdout* (String or nil): stdout of actions to read logs, or nil if no action was returned by actions_to_read_logs
73
+ # * *stderr* (String or nil): stderr of actions to read logs, or nil if no action was returned by actions_to_read_logs
74
+ # Result::
75
+ # * Hash<Symbol,Object>: Deployment log information:
76
+ # * *error* (String): Error string in case deployment logs could not be retrieved. If set then further properties will be ignored. [optional]
77
+ # * *services* (Array<String>): List of services deployed on the node
78
+ # * *deployment_info* (Hash<Symbol,Object>): Deployment metadata
79
+ # * *exit_status* (Integer or Symbol): Deployment exit status
80
+ # * *stdout* (String): Deployment stdout
81
+ # * *stderr* (String): Deployment stderr
82
+ def logs_for(node, exit_status, stdout, stderr)
83
+ # Here we should retrieve this info from somewhere.
84
+ # Based on this example, stdout is the value of the execution of the action 'cat all_logs.txt' as returned by actions_to_read_logs.
85
+ {
86
+ services: %w[unknown],
87
+ deployment_info: {},
88
+ exit_status: 0,
89
+ stdout: stdout,
90
+ stderr: ''
91
+ }
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,180 @@
1
+ require 'hybrid_platforms_conductor/log'
2
+
3
+ module HybridPlatformsConductor
4
+
5
+ module HpcPlugins
6
+
7
+ module Log
8
+
9
+ # Save logs on the remote node's file system
10
+ class RemoteFs < HybridPlatformsConductor::Log
11
+
12
+ MARKER_STDOUT = '===== STDOUT ====='
13
+ MARKER_STDERR = '===== STDERR ====='
14
+
15
+ # Get actions to save logs
16
+ # [API] - This method is mandatory.
17
+ # [API] - The following API components are accessible:
18
+ # * *@config* (Config): Main configuration API.
19
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
20
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
21
+ #
22
+ # Parameters::
23
+ # * *node* (String): Node for which logs are being saved
24
+ # * *services* (Array<String>): The list of services that have been deployed on this node
25
+ # * *deployment_info* (Hash<Symbol,Object>): Additional information to attach to the logs
26
+ # * *exit_status* (Integer or Symbol): Exit status of the deployment
27
+ # * *stdout* (String): Deployment's stdout
28
+ # * *stderr* (String): Deployment's stderr
29
+ # Result::
30
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
31
+ def actions_to_save_logs(node, services, deployment_info, exit_status, stdout, stderr)
32
+ # Create a log file to be scp with all relevant info
33
+ ssh_user = @actions_executor.connector(:ssh).ssh_user
34
+ sudo_prefix = ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(node)} "
35
+ log_file = "#{Dir.tmpdir}/hpc_deploy_logs/#{node}_#{Time.now.utc.strftime('%F_%H%M%S')}_#{ssh_user}"
36
+ [
37
+ {
38
+ ruby: proc do
39
+ FileUtils.mkdir_p File.dirname(log_file)
40
+ File.write(log_file, <<~EO_DEPLOYMENT_LOG)
41
+ #{
42
+ deployment_info.merge(
43
+ debug: log_debug? ? 'Yes' : 'No',
44
+ services: services.join(', '),
45
+ exit_status: exit_status
46
+ ).map { |property, value| "#{property}: #{value}" }.join("\n")
47
+ }
48
+ #{MARKER_STDOUT}
49
+ #{stdout}
50
+ #{MARKER_STDERR}
51
+ #{stderr}
52
+ EO_DEPLOYMENT_LOG
53
+ end,
54
+ remote_bash: "#{sudo_prefix}mkdir -p /var/log/deployments && #{sudo_prefix}chmod 600 /var/log/deployments"
55
+ },
56
+ {
57
+ scp: {
58
+ log_file => '/var/log/deployments',
59
+ :sudo => ssh_user != 'root',
60
+ :owner => 'root',
61
+ :group => 'root'
62
+ }
63
+ },
64
+ {
65
+ remote_bash: "#{sudo_prefix}chmod 600 /var/log/deployments/#{File.basename(log_file)}",
66
+ # Remove temporary files storing logs for security
67
+ ruby: proc do
68
+ File.unlink(log_file)
69
+ end
70
+ }
71
+ ]
72
+ end
73
+
74
+ # Get actions to read logs.
75
+ # If provided, this method can return some actions to be executed that will fetch logs from servers or remote nodes.
76
+ # By using this method to run actions instead of the synchronous method logs_from, such actions will be run in parallel which can greatly improve time-consuming operations when querying a lot of nodes.
77
+ # [API] - This method is optional.
78
+ # [API] - The following API components are accessible:
79
+ # * *@config* (Config): Main configuration API.
80
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
81
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
82
+ #
83
+ # Parameters::
84
+ # * *node* (String): Node for which deployment logs are being read
85
+ # Result::
86
+ # * Array< Hash<Symbol,Object> >: List of actions to be done
87
+ def actions_to_read_logs(node)
88
+ sudo_prefix = @actions_executor.connector(:ssh).ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(node)} "
89
+ [
90
+ { remote_bash: "#{sudo_prefix}cat /var/log/deployments/`#{sudo_prefix}ls -t /var/log/deployments/ | head -1`" }
91
+ ]
92
+ end
93
+
94
+ # Get deployment logs from a node.
95
+ # This method can use the result of actions previously run to read logs, as returned by the actions_to_read_logs method.
96
+ # [API] - This method is mandatory.
97
+ # [API] - The following API components are accessible:
98
+ # * *@config* (Config): Main configuration API.
99
+ # * *@nodes_handler* (NodesHandler): Nodes handler API.
100
+ # * *@actions_executor* (ActionsExecutor): Actions executor API.
101
+ #
102
+ # Parameters::
103
+ # * *node* (String): The node we want deployment logs from
104
+ # * *exit_status* (Integer, Symbol or nil): Exit status of actions to read logs, or nil if no action was returned by actions_to_read_logs
105
+ # * *stdout* (String or nil): stdout of actions to read logs, or nil if no action was returned by actions_to_read_logs
106
+ # * *stderr* (String or nil): stderr of actions to read logs, or nil if no action was returned by actions_to_read_logs
107
+ # Result::
108
+ # * Hash<Symbol,Object>: Deployment log information:
109
+ # * *error* (String): Error string in case deployment logs could not be retrieved. If set then further properties will be ignored. [optional]
110
+ # * *services* (Array<String>): List of services deployed on the node
111
+ # * *deployment_info* (Hash<Symbol,Object>): Deployment metadata
112
+ # * *exit_status* (Integer or Symbol): Deployment exit status
113
+ # * *stdout* (String): Deployment stdout
114
+ # * *stderr* (String): Deployment stderr
115
+ def logs_for(_node, exit_status, stdout, stderr)
116
+ # Expected format for stdout:
117
+ # Property1: Value1
118
+ # ...
119
+ # PropertyN: ValueN
120
+ # ===== STDOUT =====
121
+ # ...
122
+ # ===== STDERR =====
123
+ # ...
124
+ if exit_status.is_a?(Symbol)
125
+ { error: "Error: #{exit_status}\n#{stderr}" }
126
+ else
127
+ stdout_lines = stdout.split("\n")
128
+ if stdout_lines.first =~ /No such file or directory/
129
+ { error: '/var/log/deployments missing' }
130
+ else
131
+ stdout_idx = stdout_lines.index(MARKER_STDOUT)
132
+ stderr_idx = stdout_lines.index(MARKER_STDERR)
133
+ deploy_info = {}
134
+ stdout_lines[0..stdout_idx - 1].each do |line|
135
+ if line =~ /^([^:]+): (.+)$/
136
+ key_str = Regexp.last_match(1)
137
+ value = Regexp.last_match(2)
138
+ key = key_str.to_sym
139
+ # Type-cast some values
140
+ case key_str
141
+ when 'date'
142
+ # Date and time values
143
+ # Thu Nov 23 18:43:01 UTC 2017
144
+ deploy_info[key] = Time.parse("#{value} UTC")
145
+ when 'debug'
146
+ # Boolean values
147
+ # Yes
148
+ deploy_info[key] = (value == 'Yes')
149
+ when /^diff_files_.+$/, 'services'
150
+ # Array of strings
151
+ # my_file.txt, other_file.txt
152
+ deploy_info[key] = value.split(', ')
153
+ else
154
+ deploy_info[key] = value
155
+ end
156
+ else
157
+ deploy_info[:unknown_lines] = [] unless deploy_info.key?(:unknown_lines)
158
+ deploy_info[:unknown_lines] << line
159
+ end
160
+ end
161
+ services = deploy_info.delete(:services)
162
+ exit_status = deploy_info.delete(:exit_status)
163
+ {
164
+ services: services,
165
+ deployment_info: deploy_info,
166
+ exit_status: exit_status =~ /^\d+$/ ? Integer(exit_status) : exit_status.to_sym,
167
+ stdout: stdout_lines[stdout_idx + 1..stderr_idx - 1].join("\n"),
168
+ stderr: stdout_lines[stderr_idx + 1..].join("\n")
169
+ }
170
+ end
171
+ end
172
+ end
173
+
174
+ end
175
+
176
+ end
177
+
178
+ end
179
+
180
+ end
@@ -45,7 +45,7 @@ module HybridPlatformsConductor
45
45
  end
46
46
 
47
47
  end
48
- self.extend_config_dsl_with MyDSLExtension, :init_serverless_chef
48
+ extend_config_dsl_with MyDSLExtension, :init_serverless_chef
49
49
 
50
50
  # Constructor
51
51
  #
@@ -59,8 +59,8 @@ module HybridPlatformsConductor
59
59
  def initialize(
60
60
  platform_type,
61
61
  repository_path,
62
- logger: Logger.new(STDOUT),
63
- logger_stderr: Logger.new(STDERR),
62
+ logger: Logger.new($stdout),
63
+ logger_stderr: Logger.new($stderr),
64
64
  config: Config.new,
65
65
  cmd_runner: CmdRunner.new
66
66
  )
@@ -146,11 +146,10 @@ module HybridPlatformsConductor
146
146
  if info[:status].nil?
147
147
  {}
148
148
  else
149
- Hash[
150
- (info[:status][:added_files] + info[:status][:changed_files] + info[:status][:untracked_files]).
151
- sort.
152
- map { |f| [f, File.mtime("#{@repository_path}/#{f}").strftime('%F %T')] }
153
- ]
149
+ (info[:status][:added_files] + info[:status][:changed_files] + info[:status][:untracked_files]).
150
+ sort.
151
+ map { |f| [f, File.mtime("#{@repository_path}/#{f}").strftime('%F %T')] }.
152
+ to_h
154
153
  end,
155
154
  deleted_files: info[:status].nil? ? [] : info[:status][:deleted_files].sort
156
155
  }
@@ -159,40 +158,41 @@ module HybridPlatformsConductor
159
158
  package_dir = "dist/#{local_environment ? 'local' : 'prod'}/#{service}"
160
159
  package_info_file = "#{@repository_path}/#{package_dir}/hpc_package.info"
161
160
  current_package_info = File.exist?(package_info_file) ? JSON.parse(File.read(package_info_file)).transform_keys(&:to_sym) : {}
162
- unless current_package_info == package_info
163
- Bundler.with_unbundled_env do
164
- policy_file = "policyfiles/#{service}.rb"
165
- if local_environment
166
- local_policy_file = "policyfiles/#{service}.local.rb"
167
- # In local mode, we always regenerate the lock file as we may modify the run list
168
- run_list = known_cookbook_paths.any? { |cookbook_path| File.exist?("#{@repository_path}/#{cookbook_path}/hpc_test/recipes/before_run.rb") } ? ['hpc_test::before_run'] : []
169
- dsl_parser = DslParser.new
170
- dsl_parser.parse("#{@repository_path}/#{policy_file}")
171
- run_list.concat dsl_parser.calls.find { |call_info| call_info[:method] == :run_list }[:args].flatten
172
- run_list << 'hpc_test::after_run' if known_cookbook_paths.any? { |cookbook_path| File.exist?("#{@repository_path}/#{cookbook_path}/hpc_test/recipes/after_run.rb") }
173
- File.write("#{@repository_path}/#{local_policy_file}", File.read("#{@repository_path}/#{policy_file}") + "\nrun_list #{run_list.map { |recipe| "'#{recipe}'" }.join(', ')}\n")
174
- policy_file = local_policy_file
175
- end
176
- lock_file = "#{File.dirname(policy_file)}/#{File.basename(policy_file, '.rb')}.lock.json"
177
- # If the policy lock file does not exist, generate it
178
- @cmd_runner.run_cmd "cd #{@repository_path} && /opt/chef-workstation/bin/chef install #{policy_file} --chef-license accept" unless File.exist?("#{@repository_path}/#{lock_file}")
179
- extra_cp_data_bags = File.exist?("#{@repository_path}/data_bags") ? " && cp -ar data_bags/ #{package_dir}/" : ''
180
- @cmd_runner.run_cmd "cd #{@repository_path} && \
181
- #{@cmd_runner.root? ? '' : 'sudo '}rm -rf #{package_dir} && \
182
- /opt/chef-workstation/bin/chef export #{policy_file} #{package_dir} --chef-license accept#{extra_cp_data_bags}"
183
- end
184
- unless @cmd_runner.dry_run
185
- # Create secrets file
186
- secrets_file = "#{@repository_path}/#{package_dir}/data_bags/hpc_secrets/hpc_secrets.json"
187
- FileUtils.mkdir_p(File.dirname(secrets_file))
188
- File.write(secrets_file, secrets.merge(id: 'hpc_secrets').to_json)
189
- # Remember the package info
190
- File.write(package_info_file, package_info.to_json)
161
+ next if current_package_info == package_info
162
+
163
+ Bundler.with_unbundled_env do
164
+ policy_file = "policyfiles/#{service}.rb"
165
+ if local_environment
166
+ local_policy_file = "policyfiles/#{service}.local.rb"
167
+ # In local mode, we always regenerate the lock file as we may modify the run list
168
+ run_list = known_cookbook_paths.any? { |cookbook_path| File.exist?("#{@repository_path}/#{cookbook_path}/hpc_test/recipes/before_run.rb") } ? ['hpc_test::before_run'] : []
169
+ dsl_parser = DslParser.new
170
+ dsl_parser.parse("#{@repository_path}/#{policy_file}")
171
+ run_list.concat dsl_parser.calls.find { |call_info| call_info[:method] == :run_list }[:args].flatten
172
+ run_list << 'hpc_test::after_run' if known_cookbook_paths.any? { |cookbook_path| File.exist?("#{@repository_path}/#{cookbook_path}/hpc_test/recipes/after_run.rb") }
173
+ File.write("#{@repository_path}/#{local_policy_file}", File.read("#{@repository_path}/#{policy_file}") + "\nrun_list #{run_list.map { |recipe| "'#{recipe}'" }.join(', ')}\n")
174
+ policy_file = local_policy_file
191
175
  end
176
+ lock_file = "#{File.dirname(policy_file)}/#{File.basename(policy_file, '.rb')}.lock.json"
177
+ # If the policy lock file does not exist, generate it
178
+ @cmd_runner.run_cmd "cd #{@repository_path} && /opt/chef-workstation/bin/chef install #{policy_file} --chef-license accept" unless File.exist?("#{@repository_path}/#{lock_file}")
179
+ extra_cp_data_bags = File.exist?("#{@repository_path}/data_bags") ? " && cp -ar data_bags/ #{package_dir}/" : ''
180
+ @cmd_runner.run_cmd "cd #{@repository_path} && \
181
+ #{@cmd_runner.root? ? '' : 'sudo '}rm -rf #{package_dir} && \
182
+ /opt/chef-workstation/bin/chef export #{policy_file} #{package_dir} --chef-license accept#{extra_cp_data_bags}"
192
183
  end
184
+ next if @cmd_runner.dry_run
185
+
186
+ # Create secrets file
187
+ secrets_file = "#{@repository_path}/#{package_dir}/data_bags/hpc_secrets/hpc_secrets.json"
188
+ FileUtils.mkdir_p(File.dirname(secrets_file))
189
+ File.write(secrets_file, secrets.merge(id: 'hpc_secrets').to_json)
190
+ # Remember the package info
191
+ File.write(package_info_file, package_info.to_json)
193
192
  end
194
193
  end
195
194
 
195
+ # rubocop:disable Lint/UnusedMethodArgument
196
196
  # Prepare deployments.
197
197
  # This method is called just before getting and executing the actions to be deployed.
198
198
  # It is called once per platform.
@@ -208,6 +208,7 @@ module HybridPlatformsConductor
208
208
  def prepare_for_deploy(services:, secrets:, local_environment:, why_run:)
209
209
  @local_env = local_environment
210
210
  end
211
+ # rubocop:enable Lint/UnusedMethodArgument
211
212
 
212
213
  # Get the list of actions to perform to deploy on a given node.
213
214
  # Those actions can be executed in parallel with other deployments on other nodes. They must be thread safe.
@@ -242,6 +243,7 @@ module HybridPlatformsConductor
242
243
  package_name = File.basename(package_dir)
243
244
  chef_versions_file = "#{@repository_path}/chef_versions.yml"
244
245
  raise "Missing file #{chef_versions_file} specifying the Chef Infra Client version to be deployed" unless File.exist?(chef_versions_file)
246
+
245
247
  required_chef_client_version = YAML.load_file(chef_versions_file)['client']
246
248
  sudo = (@actions_executor.connector(:ssh).ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(node)} ")
247
249
  [
@@ -285,7 +287,7 @@ module HybridPlatformsConductor
285
287
  # * *:changed*: The task has been changed
286
288
  # * *:identical*: The task has not been changed
287
289
  # * *diffs* (String): Differences, if any
288
- def parse_deploy_output(stdout, stderr)
290
+ def parse_deploy_output(stdout, _stderr)
289
291
  tasks = []
290
292
  current_task = nil
291
293
  stdout.split("\n").each do |line|
@@ -293,8 +295,8 @@ module HybridPlatformsConductor
293
295
  case line.gsub(/\e\[[^\x40-\x7E]*[\x40-\x7E]/, '').strip
294
296
  when /^\* (\w+\[[^\]]+\]) action (.+)$/
295
297
  # New task
296
- task_name = $1
297
- task_action = $2
298
+ task_name = Regexp.last_match(1)
299
+ task_action = Regexp.last_match(2)
298
300
  current_task = {
299
301
  name: task_name,
300
302
  action: task_action,
@@ -303,7 +305,7 @@ module HybridPlatformsConductor
303
305
  tasks << current_task
304
306
  when /^- (.+)$/
305
307
  # Diff on the current task
306
- diff_description = $1
308
+ diff_description = Regexp.last_match(1)
307
309
  unless current_task.nil?
308
310
  current_task[:diffs] = '' unless current_task.key?(:diffs)
309
311
  current_task[:diffs] << "#{diff_description}\n"
@@ -333,25 +335,23 @@ module HybridPlatformsConductor
333
335
  impacted_recipes = []
334
336
  impacted_global = false
335
337
  files_diffs.keys.sort.each do |impacted_file|
336
- if impacted_file =~ /^policyfiles\/([^\/]+)\.rb$/
337
- log_debug "[#{impacted_file}] - Impacted service: #{$1}"
338
- impacted_services << $1
339
- elsif impacted_file =~ /^policyfiles\/([^\/]+)\.lock.json$/
340
- log_debug "[#{impacted_file}] - Impacted service: #{$1}"
341
- impacted_services << $1
342
- elsif impacted_file =~ /^nodes\/([^\/]+)\.json/
343
- log_debug "[#{impacted_file}] - Impacted node: #{$1}"
344
- impacted_nodes << $1
338
+ case impacted_file
339
+ when %r{^policyfiles/([^/]+)\.rb$}, %r{^policyfiles/([^/]+)\.lock.json$}
340
+ log_debug "[#{impacted_file}] - Impacted service: #{Regexp.last_match(1)}"
341
+ impacted_services << Regexp.last_match(1)
342
+ when %r{^nodes/([^/]+)\.json}
343
+ log_debug "[#{impacted_file}] - Impacted node: #{Regexp.last_match(1)}"
344
+ impacted_nodes << Regexp.last_match(1)
345
345
  else
346
- cookbook_path = known_cookbook_paths.find { |cookbooks_path| impacted_file =~ /^#{Regexp.escape(cookbooks_path)}\/.+$/ }
346
+ cookbook_path = known_cookbook_paths.find { |cookbooks_path| impacted_file =~ %r{^#{Regexp.escape(cookbooks_path)}/.+$} }
347
347
  if cookbook_path.nil?
348
348
  # Global file
349
349
  log_debug "[#{impacted_file}] - Global file impacted"
350
350
  impacted_global = true
351
351
  else
352
352
  # File belonging to a cookbook
353
- cookbook_name, file_path = impacted_file.match(/^#{cookbook_path}\/(\w+)\/(.+)$/)[1..2]
354
- cookbook = cookbook_name.to_sym
353
+ file_cookbook_name, file_path = impacted_file.match(%r{^#{cookbook_path}/(\w+)/(.+)$})[1..2]
354
+ cookbook = file_cookbook_name.to_sym
355
355
  # Small helper to register a recipe
356
356
  register = proc do |source, recipe_name, cookbook_name: cookbook|
357
357
  cookbook_name = cookbook_name.to_sym if cookbook_name.is_a?(String)
@@ -359,41 +359,41 @@ module HybridPlatformsConductor
359
359
  impacted_recipes << [cookbook_name, recipe_name.to_sym]
360
360
  end
361
361
  case file_path
362
- when /recipes\/(.+)\.rb/
363
- register.call('direct', $1)
364
- when /attributes\/.+\.rb/, 'metadata.rb'
362
+ when %r{recipes/(.+)\.rb}
363
+ register.call('direct', Regexp.last_match(1))
364
+ when %r{attributes/.+\.rb}, 'metadata.rb'
365
365
  # Consider all recipes are impacted
366
366
  Dir.glob("#{@repository_path}/#{cookbook_path}/#{cookbook}/recipes/*.rb") do |recipe_path|
367
367
  register.call('attributes', File.basename(recipe_path, '.rb'))
368
368
  end
369
- when /(templates|files)\/(.+)/
369
+ when %r{(templates|files)/(.+)}
370
370
  # Find recipes using this file name
371
- included_file = File.basename($2)
371
+ included_file = File.basename(Regexp.last_match(2))
372
372
  template_regexp = /["']#{Regexp.escape(included_file)}["']/
373
373
  Dir.glob("#{@repository_path}/#{cookbook_path}/#{cookbook}/recipes/*.rb") do |recipe_path|
374
374
  register.call("included file #{included_file}", File.basename(recipe_path, '.rb')) if File.read(recipe_path) =~ template_regexp
375
375
  end
376
- when /resources\/(.+)/
376
+ when %r{resources/(.+)}
377
377
  # Find any recipe using this resource
378
- included_resource = "#{cookbook}_#{File.basename($1, '.rb')}"
378
+ included_resource = "#{cookbook}_#{File.basename(Regexp.last_match(1), '.rb')}"
379
379
  resource_regexp = /(\W|^)#{Regexp.escape(included_resource)}(\W|$)/
380
380
  known_cookbook_paths.each do |cookbooks_path|
381
381
  Dir.glob("#{@repository_path}/#{cookbooks_path}/**/recipes/*.rb") do |recipe_path|
382
382
  if File.read(recipe_path) =~ resource_regexp
383
- cookbook_name, recipe_name = recipe_path.match(/#{cookbooks_path}\/(\w+)\/recipes\/(\w+)\.rb/)[1..2]
383
+ cookbook_name, recipe_name = recipe_path.match(%r{#{cookbooks_path}/(\w+)/recipes/(\w+)\.rb})[1..2]
384
384
  register.call("included resource #{included_resource}", recipe_name, cookbook_name: cookbook_name)
385
385
  end
386
386
  end
387
387
  end
388
- when /libraries\/(.+)/
388
+ when %r{libraries/(.+)}
389
389
  # Find any recipe using methods from this library
390
- lib_methods_regexps = File.read("#{@repository_path}/#{impacted_file}").scan(/(\W|^)def\s+(\w+)(\W|$)/).map { |_grp1, method_name, _grp2| /(\W|^)#{Regexp.escape(method_name)}(\W|$)/ }
390
+ lib_methods_regexps = File.read("#{@repository_path}/#{impacted_file}").scan(/(\W|^)def\s+(\w+)(\W|$)/).map { |_grp_1, method_name, _grp_2| /(\W|^)#{Regexp.escape(method_name)}(\W|$)/ }
391
391
  known_cookbook_paths.each do |cookbooks_path|
392
392
  Dir.glob("#{@repository_path}/#{cookbooks_path}/**/recipes/*.rb") do |recipe_path|
393
393
  file_content = File.read(recipe_path)
394
394
  found_lib_regexp = lib_methods_regexps.find { |regexp| file_content =~ regexp }
395
395
  unless found_lib_regexp.nil?
396
- cookbook_name, recipe_name = recipe_path.match(/#{cookbooks_path}\/(\w+)\/recipes\/(\w+)\.rb/)[1..2]
396
+ cookbook_name, recipe_name = recipe_path.match(%r{#{cookbooks_path}/(\w+)/recipes/(\w+)\.rb})[1..2]
397
397
  register.call("included library helper #{found_lib_regexp.source[6..-7]}", recipe_name, cookbook_name: cookbook_name)
398
398
  end
399
399
  end
@@ -476,6 +476,7 @@ module HybridPlatformsConductor
476
476
  dsl_parser.parse(policy_file)
477
477
  run_list_call = dsl_parser.calls.find { |call_info| call_info[:method] == :run_list }
478
478
  raise "Policy #{policy} has no run list defined in #{policy_file}" if run_list_call.nil?
479
+
479
480
  run_list_call[:args].map { |recipe_def| decode_recipe(recipe_def) }
480
481
  end
481
482
 
@@ -493,13 +494,14 @@ module HybridPlatformsConductor
493
494
  # * Symbol: The cookbook name
494
495
  # * Symbol: The recipe name
495
496
  def decode_recipe(recipe_def)
496
- recipe_def = $1 if recipe_def =~ /^recipe\[(.+)\]$/
497
+ recipe_def = Regexp.last_match(1) if recipe_def =~ /^recipe\[(.+)\]$/
497
498
  cookbook, recipe = recipe_def.split('::').map(&:to_sym)
498
499
  recipe = :default if recipe.nil?
499
500
  # Find the cookbook it belongs to
500
501
  cookbook_dir = known_cookbook_paths.find { |cookbook_path| File.exist?("#{@repository_path}/#{cookbook_path}/#{cookbook}") }
501
502
  raise "Unknown recipe #{cookbook}::#{recipe} from cookbook #{@repository_path}/#{cookbook_dir}/#{cookbook}." if !cookbook_dir.nil? && !File.exist?("#{@repository_path}/#{cookbook_dir}/#{cookbook}/recipes/#{recipe}.rb")
502
- return cookbook_dir, cookbook, recipe
503
+
504
+ [cookbook_dir, cookbook, recipe]
503
505
  end
504
506
 
505
507
  private