hybrid_platforms_conductor 32.16.4 → 33.0.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 +42 -0
- data/README.md +6 -3
- data/bin/check-node +0 -1
- data/bin/deploy +0 -1
- data/bin/get_impacted_nodes +0 -1
- data/bin/last_deploys +12 -8
- data/bin/nodes_to_deploy +6 -6
- data/bin/setup +6 -6
- data/bin/topograph +1 -1
- data/docs/config_dsl.md +45 -1
- data/docs/executables.md +6 -7
- data/docs/executables/check-node.md +3 -3
- data/docs/executables/deploy.md +3 -3
- data/docs/executables/dump_nodes_json.md +3 -3
- data/docs/executables/test.md +3 -3
- data/docs/executables/topograph.md +3 -3
- data/docs/gen/mermaid/README.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
- data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
- data/docs/plugins.md +47 -0
- data/docs/plugins/connector/ssh.md +1 -1
- data/docs/plugins/log/remote_fs.md +26 -0
- data/docs/plugins/secrets_reader/cli.md +31 -0
- data/docs/plugins/secrets_reader/thycotic.md +46 -0
- data/docs/plugins/test/bitbucket_conf.md +1 -1
- data/docs/plugins/test/check_deploy_and_idempotence.md +1 -1
- data/docs/plugins/test/connection.md +1 -0
- data/docs/plugins/test/deploy_removes_root_access.md +1 -1
- data/docs/plugins/test/file_system.md +1 -0
- data/docs/plugins/test/github_ci.md +48 -0
- data/docs/plugins/test/hostname.md +1 -0
- data/docs/plugins/test/ip.md +1 -0
- data/docs/plugins/test/jenkins_ci_conf.md +1 -1
- data/docs/plugins/test/jenkins_ci_masters_ok.md +1 -1
- data/docs/plugins/test/local_users.md +1 -0
- data/docs/plugins/test/mounts.md +1 -0
- data/docs/plugins/test/orphan_files.md +1 -0
- data/docs/plugins/test/ports.md +1 -0
- data/docs/plugins/test/spectre.md +1 -0
- data/docs/plugins/test/vulnerabilities.md +1 -0
- data/lib/hybrid_platforms_conductor/action.rb +4 -4
- data/lib/hybrid_platforms_conductor/actions_executor.rb +45 -43
- data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
- data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
- data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
- data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
- data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
- data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
- data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +63 -0
- data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
- data/lib/hybrid_platforms_conductor/config.rb +7 -4
- data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
- data/lib/hybrid_platforms_conductor/connector.rb +5 -2
- data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
- data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
- data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
- data/lib/hybrid_platforms_conductor/deployer.rb +275 -224
- data/lib/hybrid_platforms_conductor/executable.rb +20 -15
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
- data/lib/hybrid_platforms_conductor/hpc_plugins/log/my_log_plugin.rb.sample +100 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +180 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
- data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
- data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +77 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/my_secrets_reader_plugin.rb.sample +46 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +90 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/connection.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +7 -21
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +21 -22
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +31 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +3 -1
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +4 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +5 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +5 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +13 -10
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +5 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +7 -7
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +27 -25
- data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
- data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
- data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
- data/lib/hybrid_platforms_conductor/log.rb +31 -0
- data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
- data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
- data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
- data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
- data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
- data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
- data/lib/hybrid_platforms_conductor/plugins.rb +14 -8
- data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
- data/lib/hybrid_platforms_conductor/report.rb +2 -2
- data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
- data/lib/hybrid_platforms_conductor/secrets_reader.rb +31 -0
- data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
- data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +18 -0
- data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
- data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
- data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
- data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
- data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
- data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test.rb +33 -12
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +16 -11
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +23 -18
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +67 -49
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +20 -14
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +63 -50
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +35 -35
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +73 -54
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +106 -91
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
- data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +10 -12
- data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
- data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
- data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
- data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +43 -5
- data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +199 -216
- data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +223 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +64 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +268 -0
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
- data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
- data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
- data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
- data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
- data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
- data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
- data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
- data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
- data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
- data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
- data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +5 -4
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +72 -0
- data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
- data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
- data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
- data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
- data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +159 -113
- data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +299 -160
- data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
- data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
- data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -8
- data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -196
- data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
- data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
- data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
- data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
- data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
- data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
- data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
- data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
- data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +245 -56
- data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
- data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
- data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
- data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
- 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
- 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
- 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
- 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
- data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
- data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
- data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
- data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +84 -0
- data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +105 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
- data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
- data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +45 -0
- data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
- data/spec/spec_helper.rb +17 -18
- data/tools/check_md +16 -20
- data/tools/generate_mermaid +1 -1
- metadata +82 -13
- 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
|
-
|
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(
|
63
|
-
logger_stderr: Logger.new(
|
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
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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,
|
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 =
|
297
|
-
task_action =
|
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 =
|
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
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
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 =~
|
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
|
-
|
354
|
-
cookbook =
|
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 /
|
363
|
-
register.call('direct',
|
364
|
-
when
|
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
|
369
|
+
when %r{(templates|files)/(.+)}
|
370
370
|
# Find recipes using this file name
|
371
|
-
included_file = File.basename(
|
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 /
|
376
|
+
when %r{resources/(.+)}
|
377
377
|
# Find any recipe using this resource
|
378
|
-
included_resource = "#{cookbook}_#{File.basename(
|
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(
|
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 /
|
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 { |
|
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(
|
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 =
|
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
|
-
|
503
|
+
|
504
|
+
[cookbook_dir, cookbook, recipe]
|
503
505
|
end
|
504
506
|
|
505
507
|
private
|