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
data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb
ADDED
@@ -0,0 +1,268 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
describe HybridPlatformsConductor::Deployer do
|
4
|
+
|
5
|
+
context 'when checking secrets_reader plugins' do
|
6
|
+
|
7
|
+
context 'with thycotic' do
|
8
|
+
|
9
|
+
# Setup a platform for tests
|
10
|
+
#
|
11
|
+
# Parameters::
|
12
|
+
# * *additional_config* (String): Additional config
|
13
|
+
# * *platform_info* (Hash): Platform configuration [default: 1 node having 1 service]
|
14
|
+
# * *block* (Proc): Code called when the platform is setup
|
15
|
+
def with_test_platform_for_thycotic_test(
|
16
|
+
additional_config,
|
17
|
+
platform_info: {
|
18
|
+
nodes: { 'node' => { services: %w[service] } },
|
19
|
+
deployable_services: %w[service]
|
20
|
+
},
|
21
|
+
&block
|
22
|
+
)
|
23
|
+
with_test_platform(
|
24
|
+
platform_info,
|
25
|
+
additional_config: "read_secrets_from :thycotic\n#{additional_config}",
|
26
|
+
&block
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Mock calls being made to a Thycotic SOAP API using Savon
|
31
|
+
#
|
32
|
+
# Parameters::
|
33
|
+
# * *thycotic_url* (String): Mocked URL
|
34
|
+
# * *secret_id* (String): The mocked secret ID
|
35
|
+
# * *mocked_secrets_file* (String or nil): The mocked secrets file stored in Thycotic, or nil to mock a missing secret
|
36
|
+
# * *user* (String or nil): The user to be expected, or nil if it should be read from netrc [default: nil]
|
37
|
+
# * *password* (String or nil): The password to be expected, or nil if it should be read from netrc [default: nil]
|
38
|
+
def mock_thycotic_file_download_on(thycotic_url, secret_id, mocked_secrets_file, user: nil, password: nil)
|
39
|
+
if user.nil?
|
40
|
+
user = 'thycotic_user_from_netrc'
|
41
|
+
password = 'thycotic_password_from_netrc'
|
42
|
+
expect(HybridPlatformsConductor::Credentials).to receive(:with_credentials_for) do |id, _logger, _logger_stderr, url: nil, &client_code|
|
43
|
+
expect(id).to eq :thycotic
|
44
|
+
expect(url).to eq thycotic_url
|
45
|
+
client_code.call user, password
|
46
|
+
end
|
47
|
+
end
|
48
|
+
# Mock the Savon calls
|
49
|
+
mocked_savon_client = instance_double Savon::Client
|
50
|
+
expect(Savon).to receive(:client) do |params|
|
51
|
+
expect(params[:wsdl]).to eq "#{thycotic_url}/webservices/SSWebservice.asmx?wsdl"
|
52
|
+
expect(params[:ssl_verify_mode]).to eq :none
|
53
|
+
mocked_savon_client
|
54
|
+
end
|
55
|
+
expect(mocked_savon_client).to receive(:call).with(
|
56
|
+
:authenticate,
|
57
|
+
message: {
|
58
|
+
username: user,
|
59
|
+
password: password,
|
60
|
+
domain: 'thycotic_auth_domain'
|
61
|
+
}
|
62
|
+
).and_return(authenticate_response: { authenticate_result: { token: 'soap_token' } })
|
63
|
+
expect(mocked_savon_client).to receive(:call).with(
|
64
|
+
:get_secret,
|
65
|
+
message: {
|
66
|
+
token: 'soap_token',
|
67
|
+
secretId: secret_id
|
68
|
+
}
|
69
|
+
) do
|
70
|
+
{
|
71
|
+
get_secret_response: {
|
72
|
+
get_secret_result:
|
73
|
+
if mocked_secrets_file
|
74
|
+
{ secret: { items: { secret_item: { id: '4242' } } } }
|
75
|
+
else
|
76
|
+
{ errors: { string: 'Access Denied' }, secret_error: { error_code: 'LOAD', error_message: 'Access Denied', allows_response: false } }
|
77
|
+
end
|
78
|
+
}
|
79
|
+
}
|
80
|
+
end
|
81
|
+
if mocked_secrets_file
|
82
|
+
expect(mocked_savon_client).to receive(:call).with(
|
83
|
+
:download_file_attachment_by_item_id,
|
84
|
+
message: {
|
85
|
+
token: 'soap_token',
|
86
|
+
secretId: secret_id,
|
87
|
+
secretItemId: '4242'
|
88
|
+
}
|
89
|
+
) do
|
90
|
+
{
|
91
|
+
download_file_attachment_by_item_id_response: {
|
92
|
+
download_file_attachment_by_item_id_result: {
|
93
|
+
file_attachment: Base64.encode64(mocked_secrets_file)
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
ENV['hpc_domain_for_thycotic'] = 'thycotic_auth_domain'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'gets secrets from a Thycotic Secret Server' do
|
103
|
+
with_test_platform_for_thycotic_test(
|
104
|
+
<<~EO_CONFIG
|
105
|
+
secrets_from_thycotic(
|
106
|
+
thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
|
107
|
+
secret_id: 1107
|
108
|
+
)
|
109
|
+
EO_CONFIG
|
110
|
+
) do
|
111
|
+
mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', 1107, '{ "secret_name": "secret_value" }')
|
112
|
+
expect(test_services_handler).to receive(:package).with(
|
113
|
+
services: { 'node' => %w[service] },
|
114
|
+
secrets: { 'secret_name' => 'secret_value' },
|
115
|
+
local_environment: false
|
116
|
+
) { raise 'Abort as testing secrets is enough' }
|
117
|
+
expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Abort as testing secrets is enough'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'gets secrets from a Thycotic Secret Server for several nodes' do
|
122
|
+
additional_config = <<~EO_CONFIG
|
123
|
+
secrets_from_thycotic(
|
124
|
+
thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
|
125
|
+
secret_id: 1107
|
126
|
+
)
|
127
|
+
EO_CONFIG
|
128
|
+
with_test_platform_for_thycotic_test(
|
129
|
+
additional_config,
|
130
|
+
platform_info: {
|
131
|
+
nodes: { 'node1' => { services: %w[service1] }, 'node2' => { services: %w[service2] } },
|
132
|
+
deployable_services: %w[service1 service2]
|
133
|
+
}
|
134
|
+
) do
|
135
|
+
mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', 1107, '{ "secret_name": "secret_value" }')
|
136
|
+
expect(test_services_handler).to receive(:package).with(
|
137
|
+
services: { 'node1' => %w[service1], 'node2' => %w[service2] },
|
138
|
+
secrets: { 'secret_name' => 'secret_value' },
|
139
|
+
local_environment: false
|
140
|
+
) { raise 'Abort as testing secrets is enough' }
|
141
|
+
expect { test_deployer.deploy_on(%w[node1 node2]) }.to raise_error 'Abort as testing secrets is enough'
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'gets secrets from a Thycotic Secret Server using env variables' do
|
146
|
+
with_test_platform_for_thycotic_test(
|
147
|
+
<<~EO_CONFIG
|
148
|
+
secrets_from_thycotic(
|
149
|
+
thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
|
150
|
+
secret_id: 1107
|
151
|
+
)
|
152
|
+
EO_CONFIG
|
153
|
+
) do
|
154
|
+
mock_thycotic_file_download_on(
|
155
|
+
'https://my_thycotic.domain.com/SecretServer',
|
156
|
+
1107,
|
157
|
+
'{ "secret_name": "secret_value" }',
|
158
|
+
user: 'thycotic_user_from_env',
|
159
|
+
password: 'thycotic_password_from_env'
|
160
|
+
)
|
161
|
+
ENV['hpc_user_for_thycotic'] = 'thycotic_user_from_env'
|
162
|
+
ENV['hpc_password_for_thycotic'] = 'thycotic_password_from_env'
|
163
|
+
expect(test_services_handler).to receive(:package).with(
|
164
|
+
services: { 'node' => %w[service] },
|
165
|
+
secrets: { 'secret_name' => 'secret_value' },
|
166
|
+
local_environment: false
|
167
|
+
) { raise 'Abort as testing secrets is enough' }
|
168
|
+
expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Abort as testing secrets is enough'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'gets secrets from several Thycotic Secret Servers' do
|
173
|
+
additional_config = <<~EO_CONFIG
|
174
|
+
secrets_from_thycotic(
|
175
|
+
thycotic_url: 'https://my_thycotic1.domain.com/SecretServer',
|
176
|
+
secret_id: 110701
|
177
|
+
)
|
178
|
+
for_nodes('node2') do
|
179
|
+
secrets_from_thycotic(
|
180
|
+
thycotic_url: 'https://my_thycotic2.domain.com/SecretServer',
|
181
|
+
secret_id: 110702
|
182
|
+
)
|
183
|
+
end
|
184
|
+
EO_CONFIG
|
185
|
+
with_test_platform_for_thycotic_test(
|
186
|
+
additional_config,
|
187
|
+
platform_info: {
|
188
|
+
nodes: { 'node1' => { services: %w[service1] }, 'node2' => { services: %w[service2] } },
|
189
|
+
deployable_services: %w[service1 service2]
|
190
|
+
}
|
191
|
+
) do
|
192
|
+
mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110_701, '{ "secret1": "value1" }')
|
193
|
+
mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110_702, '{ "secret2": "value2" }')
|
194
|
+
expect(test_services_handler).to receive(:package).with(
|
195
|
+
services: { 'node1' => %w[service1], 'node2' => %w[service2] },
|
196
|
+
secrets: { 'secret1' => 'value1', 'secret2' => 'value2' },
|
197
|
+
local_environment: false
|
198
|
+
) { raise 'Abort as testing secrets is enough' }
|
199
|
+
expect { test_deployer.deploy_on(%w[node1 node2]) }.to raise_error 'Abort as testing secrets is enough'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'merges secrets from several Thycotic Secret Servers' do
|
204
|
+
with_test_platform_for_thycotic_test(
|
205
|
+
<<~EO_CONFIG
|
206
|
+
secrets_from_thycotic(
|
207
|
+
thycotic_url: 'https://my_thycotic1.domain.com/SecretServer',
|
208
|
+
secret_id: 110701
|
209
|
+
)
|
210
|
+
for_nodes('node') do
|
211
|
+
secrets_from_thycotic(
|
212
|
+
thycotic_url: 'https://my_thycotic2.domain.com/SecretServer',
|
213
|
+
secret_id: 110702
|
214
|
+
)
|
215
|
+
end
|
216
|
+
EO_CONFIG
|
217
|
+
) do
|
218
|
+
mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110_701, '{ "secret1": "value1", "secret2": "value2" }')
|
219
|
+
mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110_702, '{ "secret2": "value2", "secret3": "value3" }')
|
220
|
+
expect(test_services_handler).to receive(:package).with(
|
221
|
+
services: { 'node' => %w[service] },
|
222
|
+
secrets: { 'secret1' => 'value1', 'secret2' => 'value2', 'secret3' => 'value3' },
|
223
|
+
local_environment: false
|
224
|
+
) { raise 'Abort as testing secrets is enough' }
|
225
|
+
expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Abort as testing secrets is enough'
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'fails in case of secrets conflicts from several Thycotic Secret Servers' do
|
230
|
+
with_test_platform_for_thycotic_test(
|
231
|
+
<<~EO_CONFIG
|
232
|
+
secrets_from_thycotic(
|
233
|
+
thycotic_url: 'https://my_thycotic1.domain.com/SecretServer',
|
234
|
+
secret_id: 110701
|
235
|
+
)
|
236
|
+
for_nodes('node') do
|
237
|
+
secrets_from_thycotic(
|
238
|
+
thycotic_url: 'https://my_thycotic2.domain.com/SecretServer',
|
239
|
+
secret_id: 110702
|
240
|
+
)
|
241
|
+
end
|
242
|
+
EO_CONFIG
|
243
|
+
) do
|
244
|
+
mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110_701, '{ "secret1": "value1", "secret2": "value2" }')
|
245
|
+
mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110_702, '{ "secret2": "other_value", "secret3": "value3" }')
|
246
|
+
expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Thycotic secret secret2 served by https://my_thycotic2.domain.com/SecretServer from secret ID 110702 has conflicting values between different secrets.'
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'fails to get secrets from a missing Thycotic Secret Server' do
|
251
|
+
with_test_platform_for_thycotic_test(
|
252
|
+
<<~EO_CONFIG
|
253
|
+
secrets_from_thycotic(
|
254
|
+
thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
|
255
|
+
secret_id: 1107
|
256
|
+
)
|
257
|
+
EO_CONFIG
|
258
|
+
) do
|
259
|
+
mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', 1107, nil)
|
260
|
+
expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Unable to fetch secret file ID 1107 from https://my_thycotic.domain.com/SecretServer'
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
describe HybridPlatformsConductor::NodesHandler do
|
2
2
|
|
3
|
-
context 'checking CMDB plugin Config' do
|
3
|
+
context 'when checking CMDB plugin Config' do
|
4
4
|
|
5
5
|
it 'sets global metadata' do
|
6
6
|
with_test_platform(
|
7
7
|
{ nodes: { 'node1' => {} } },
|
8
|
-
|
9
|
-
'set_metadata(my_property: \'my_value\')'
|
8
|
+
additional_config: 'set_metadata(my_property: \'my_value\')'
|
10
9
|
) do
|
11
10
|
expect(cmdb(:config).get_others(['node1'], {})).to eq('node1' => { my_property: 'my_value' })
|
12
11
|
end
|
@@ -15,15 +14,14 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
15
14
|
it 'sets different metadata for different nodes' do
|
16
15
|
with_test_platform(
|
17
16
|
{ nodes: { 'node1' => {}, 'node2' => {} } },
|
18
|
-
|
19
|
-
|
20
|
-
for_nodes(
|
21
|
-
|
22
|
-
'
|
17
|
+
additional_config: <<~'EO_CONFIG'
|
18
|
+
for_nodes('node1') { set_metadata(my_property_1: 'my_value1', my_property_2: 'my_value2') }
|
19
|
+
for_nodes('node2') { set_metadata(my_property_2: 'my_value3', my_property_3: 'my_value4') }
|
20
|
+
EO_CONFIG
|
23
21
|
) do
|
24
22
|
expect(cmdb(:config).get_others(%w[node1 node2], {})).to eq(
|
25
|
-
'node1' => {
|
26
|
-
'node2' => {
|
23
|
+
'node1' => { my_property_1: 'my_value1', my_property_2: 'my_value2' },
|
24
|
+
'node2' => { my_property_2: 'my_value3', my_property_3: 'my_value4' }
|
27
25
|
)
|
28
26
|
end
|
29
27
|
end
|
@@ -1,57 +1,66 @@
|
|
1
1
|
describe HybridPlatformsConductor::NodesHandler do
|
2
2
|
|
3
|
-
context 'checking CMDB plugin HostIp' do
|
3
|
+
context 'when checking CMDB plugin HostIp' do
|
4
4
|
|
5
5
|
it 'makes sure to have hostname set to compute host_ip' do
|
6
|
-
with_test_platform do
|
6
|
+
with_test_platform({}) do
|
7
7
|
expect(cmdb(:host_ip).property_dependencies[:host_ip]).to eq :hostname
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'does not return a host IP when hostname is not set' do
|
12
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
12
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
13
13
|
expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { property: 'value' } })).to eq({})
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns a host IP when hostname is set' do
|
18
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
19
|
-
with_cmd_runner_mocked
|
18
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
19
|
+
with_cmd_runner_mocked [
|
20
20
|
['getent hosts my_domain.my_host', proc { [0, '192.168.42.42 my_domain.my_host', ''] }]
|
21
|
-
]
|
21
|
+
] do
|
22
22
|
expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq('test_node' => '192.168.42.42')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'does not return a host IP when getent can\'t retrieve it' do
|
28
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
29
|
-
with_cmd_runner_mocked
|
28
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
29
|
+
with_cmd_runner_mocked [
|
30
30
|
['getent hosts my_domain.my_host', proc { [0, '', ''] }]
|
31
|
-
]
|
31
|
+
] do
|
32
32
|
expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq({})
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns a host IPs for the maximum hosts it can from the list' do
|
38
|
-
with_test_platform(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
with_test_platform(
|
39
|
+
{
|
40
|
+
nodes: {
|
41
|
+
'test_node1' => {},
|
42
|
+
'test_node2' => {},
|
43
|
+
'test_node3' => {},
|
44
|
+
'test_node4' => {}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
) do
|
48
|
+
with_cmd_runner_mocked [
|
45
49
|
['getent hosts my_domain.my_host1', proc { [0, '192.168.42.1 my_domain.my_host1', ''] }],
|
46
50
|
['getent hosts my_domain.my_host2', proc { [0, '', ''] }],
|
47
|
-
['getent hosts my_domain.my_host4', proc { [0, '192.168.42.4 my_domain.my_host4', ''] }]
|
48
|
-
]
|
49
|
-
expect(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
['getent hosts my_domain.my_host4', proc { [0, '192.168.42.4 my_domain.my_host4', ''] }]
|
52
|
+
] do
|
53
|
+
expect(
|
54
|
+
cmdb(:host_ip).get_host_ip(
|
55
|
+
['test_node'],
|
56
|
+
{
|
57
|
+
'test_node1' => { hostname: 'my_domain.my_host1' },
|
58
|
+
'test_node2' => { hostname: 'my_domain.my_host2' },
|
59
|
+
'test_node3' => {},
|
60
|
+
'test_node4' => { hostname: 'my_domain.my_host4' }
|
61
|
+
}
|
62
|
+
)
|
63
|
+
).to eq(
|
55
64
|
'test_node1' => '192.168.42.1',
|
56
65
|
'test_node4' => '192.168.42.4'
|
57
66
|
)
|
@@ -1,49 +1,49 @@
|
|
1
1
|
describe HybridPlatformsConductor::NodesHandler do
|
2
2
|
|
3
|
-
context 'checking CMDB plugin HostKeys' do
|
3
|
+
context 'when checking CMDB plugin HostKeys' do
|
4
4
|
|
5
5
|
it 'makes sure to have hostname or host_ip set to compute host_keys' do
|
6
|
-
with_test_platform do
|
6
|
+
with_test_platform({}) do
|
7
7
|
expect(cmdb(:host_keys).property_dependencies[:host_keys].sort).to eq %i[hostname host_ip].sort
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'does not return host keys when neither hostname nor host_ip are set' do
|
12
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
12
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
13
13
|
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { property: 'value' } })).to eq({})
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns host keys when hostname is set' do
|
18
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
19
|
-
with_cmd_runner_mocked
|
18
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
19
|
+
with_cmd_runner_mocked [
|
20
20
|
['ssh-keyscan my_host.my_domain', proc { [0, "my_host.my_domain ssh-rsa fake_host_key\n", ''] }]
|
21
|
-
]
|
21
|
+
] do
|
22
22
|
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { hostname: 'my_host.my_domain' } })).to eq('test_node' => ['ssh-rsa fake_host_key'])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'returns host keys when host_ip is set' do
|
28
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
29
|
-
with_cmd_runner_mocked
|
28
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
29
|
+
with_cmd_runner_mocked [
|
30
30
|
['ssh-keyscan 192.168.42.42', proc { [0, "192.168.42.42 ssh-rsa fake_host_key\n", ''] }]
|
31
|
-
]
|
31
|
+
] do
|
32
32
|
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq('test_node' => ['ssh-rsa fake_host_key'])
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'returns several host keys' do
|
38
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
39
|
-
with_cmd_runner_mocked
|
38
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
39
|
+
with_cmd_runner_mocked [
|
40
40
|
['ssh-keyscan 192.168.42.42', proc do
|
41
|
-
[0, <<~
|
41
|
+
[0, <<~EO_STDOUT, '']
|
42
42
|
192.168.42.42 ssh-rsa fake_host_key_rsa
|
43
43
|
192.168.42.42 ssh-ed25519 fake_host_key_ed25519
|
44
|
-
|
44
|
+
EO_STDOUT
|
45
45
|
end]
|
46
|
-
]
|
46
|
+
] do
|
47
47
|
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq('test_node' => [
|
48
48
|
'ssh-rsa fake_host_key_rsa',
|
49
49
|
'ssh-ed25519 fake_host_key_ed25519'
|
@@ -53,74 +53,87 @@ describe HybridPlatformsConductor::NodesHandler do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'returns several host keys and ignores comments from ssh-keyscan' do
|
56
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
57
|
-
with_cmd_runner_mocked
|
56
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
57
|
+
with_cmd_runner_mocked [
|
58
58
|
['ssh-keyscan 192.168.42.42', proc do
|
59
|
-
[0, <<~
|
59
|
+
[0, <<~EO_STDOUT, '']
|
60
60
|
# That's a comment
|
61
61
|
192.168.42.42 ssh-rsa fake_host_key_rsa
|
62
62
|
# And another one
|
63
63
|
192.168.42.42 ssh-ed25519 fake_host_key_ed25519
|
64
64
|
# Woot third!
|
65
|
-
|
65
|
+
EO_STDOUT
|
66
66
|
end]
|
67
|
-
]
|
68
|
-
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq(
|
69
|
-
'
|
70
|
-
|
71
|
-
|
67
|
+
] do
|
68
|
+
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq(
|
69
|
+
'test_node' => [
|
70
|
+
'ssh-rsa fake_host_key_rsa',
|
71
|
+
'ssh-ed25519 fake_host_key_ed25519'
|
72
|
+
].sort
|
73
|
+
)
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
76
78
|
it 'returns host keys sorted' do
|
77
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
78
|
-
with_cmd_runner_mocked
|
79
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
80
|
+
with_cmd_runner_mocked [
|
79
81
|
['ssh-keyscan 192.168.42.42', proc do
|
80
|
-
[0, <<~
|
82
|
+
[0, <<~EO_STDOUT, '']
|
81
83
|
192.168.42.42 ssh-dsa fake_host_key_dsa
|
82
84
|
192.168.42.42 ssh-rsa fake_host_key_rsa
|
83
85
|
192.168.42.42 ssh-ed25519 fake_host_key_ed25519
|
84
|
-
|
86
|
+
EO_STDOUT
|
85
87
|
end]
|
86
|
-
]
|
87
|
-
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq(
|
88
|
-
'
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
] do
|
89
|
+
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq(
|
90
|
+
'test_node' => [
|
91
|
+
'ssh-dsa fake_host_key_dsa',
|
92
|
+
'ssh-ed25519 fake_host_key_ed25519',
|
93
|
+
'ssh-rsa fake_host_key_rsa'
|
94
|
+
]
|
95
|
+
)
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
96
100
|
it 'does not return host keys when ssh-keyscan can\'t retrieve them' do
|
97
|
-
with_test_platform(nodes: { 'test_node' => {} }) do
|
98
|
-
with_cmd_runner_mocked
|
101
|
+
with_test_platform({ nodes: { 'test_node' => {} } }) do
|
102
|
+
with_cmd_runner_mocked [
|
99
103
|
['ssh-keyscan 192.168.42.42', proc { [0, '', ''] }]
|
100
|
-
]
|
104
|
+
] do
|
101
105
|
expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq({})
|
102
106
|
end
|
103
107
|
end
|
104
108
|
end
|
105
109
|
|
106
110
|
it 'returns host keys for the maximum hosts it can from the list' do
|
107
|
-
with_test_platform(
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
with_test_platform(
|
112
|
+
{
|
113
|
+
nodes: {
|
114
|
+
'test_node1' => {},
|
115
|
+
'test_node2' => {},
|
116
|
+
'test_node3' => {},
|
117
|
+
'test_node4' => {}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
) do
|
121
|
+
with_cmd_runner_mocked [
|
114
122
|
['ssh-keyscan 192.168.42.1', proc { [0, "192.168.42.1 ssh-rsa fake_host_key_1\n", ''] }],
|
115
123
|
['ssh-keyscan 192.168.42.2', proc { [0, '', ''] }],
|
116
|
-
['ssh-keyscan my_host_4.my_domain', proc { [0, "my_host_4.my_domain ssh-rsa fake_host_key_4\n", ''] }]
|
117
|
-
]
|
118
|
-
expect(
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
+
['ssh-keyscan my_host_4.my_domain', proc { [0, "my_host_4.my_domain ssh-rsa fake_host_key_4\n", ''] }]
|
125
|
+
] do
|
126
|
+
expect(
|
127
|
+
cmdb(:host_keys).get_host_keys(
|
128
|
+
['test_node'],
|
129
|
+
{
|
130
|
+
'test_node1' => { host_ip: '192.168.42.1' },
|
131
|
+
'test_node2' => { host_ip: '192.168.42.2' },
|
132
|
+
'test_node3' => {},
|
133
|
+
'test_node4' => { hostname: 'my_host_4.my_domain' }
|
134
|
+
}
|
135
|
+
)
|
136
|
+
).to eq(
|
124
137
|
'test_node1' => ['ssh-rsa fake_host_key_1'],
|
125
138
|
'test_node4' => ['ssh-rsa fake_host_key_4']
|
126
139
|
)
|