hybrid_platforms_conductor 33.0.0 → 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 +6 -0
- data/bin/check-node +0 -1
- data/bin/deploy +0 -1
- data/bin/get_impacted_nodes +0 -1
- data/bin/last_deploys +8 -7
- data/bin/nodes_to_deploy +2 -2
- data/bin/setup +6 -6
- data/bin/topograph +1 -1
- data/lib/hybrid_platforms_conductor/action.rb +4 -4
- data/lib/hybrid_platforms_conductor/actions_executor.rb +37 -42
- 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 +4 -3
- 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 +95 -96
- 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/remote_fs.rb +6 -5
- 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 +8 -6
- data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +7 -4
- 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/deploy_freshness.rb +0 -1
- 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 +19 -21
- 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 +2 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
- 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 +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
- 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 +4 -6
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
- data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
- 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 +2 -2
- 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 +13 -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 +2 -2
- data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
- data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
- 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 +6 -6
- 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 +7 -11
- data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +34 -26
- data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +21 -21
- 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 +21 -20
- data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +70 -55
- 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 +4 -3
- 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 +5 -5
- 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 +13 -15
- data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +289 -307
- 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 -9
- data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -14
- 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 +216 -14
- 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 +3 -1
- data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +3 -1
- 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 +4 -4
- 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 +43 -13
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -1152
@@ -37,7 +37,7 @@ module HybridPlatformsConductor
|
|
37
37
|
{
|
38
38
|
ruby: proc do
|
39
39
|
FileUtils.mkdir_p File.dirname(log_file)
|
40
|
-
File.write(log_file, <<~
|
40
|
+
File.write(log_file, <<~EO_DEPLOYMENT_LOG)
|
41
41
|
#{
|
42
42
|
deployment_info.merge(
|
43
43
|
debug: log_debug? ? 'Yes' : 'No',
|
@@ -49,7 +49,7 @@ module HybridPlatformsConductor
|
|
49
49
|
#{stdout}
|
50
50
|
#{MARKER_STDERR}
|
51
51
|
#{stderr}
|
52
|
-
|
52
|
+
EO_DEPLOYMENT_LOG
|
53
53
|
end,
|
54
54
|
remote_bash: "#{sudo_prefix}mkdir -p /var/log/deployments && #{sudo_prefix}chmod 600 /var/log/deployments"
|
55
55
|
},
|
@@ -112,7 +112,7 @@ module HybridPlatformsConductor
|
|
112
112
|
# * *exit_status* (Integer or Symbol): Deployment exit status
|
113
113
|
# * *stdout* (String): Deployment stdout
|
114
114
|
# * *stderr* (String): Deployment stderr
|
115
|
-
def logs_for(
|
115
|
+
def logs_for(_node, exit_status, stdout, stderr)
|
116
116
|
# Expected format for stdout:
|
117
117
|
# Property1: Value1
|
118
118
|
# ...
|
@@ -133,7 +133,8 @@ module HybridPlatformsConductor
|
|
133
133
|
deploy_info = {}
|
134
134
|
stdout_lines[0..stdout_idx - 1].each do |line|
|
135
135
|
if line =~ /^([^:]+): (.+)$/
|
136
|
-
key_str
|
136
|
+
key_str = Regexp.last_match(1)
|
137
|
+
value = Regexp.last_match(2)
|
137
138
|
key = key_str.to_sym
|
138
139
|
# Type-cast some values
|
139
140
|
case key_str
|
@@ -164,7 +165,7 @@ module HybridPlatformsConductor
|
|
164
165
|
deployment_info: deploy_info,
|
165
166
|
exit_status: exit_status =~ /^\d+$/ ? Integer(exit_status) : exit_status.to_sym,
|
166
167
|
stdout: stdout_lines[stdout_idx + 1..stderr_idx - 1].join("\n"),
|
167
|
-
stderr: stdout_lines[stderr_idx + 1
|
168
|
+
stderr: stdout_lines[stderr_idx + 1..].join("\n")
|
168
169
|
}
|
169
170
|
end
|
170
171
|
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
|
data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
CHANGED
@@ -29,6 +29,10 @@ module HybridPlatformsConductor
|
|
29
29
|
instance_eval(File.read(source))
|
30
30
|
end
|
31
31
|
|
32
|
+
# Intercept all missing methods
|
33
|
+
#
|
34
|
+
# Parameters::
|
35
|
+
# * *method_name* (Symbol): The missing method being called
|
32
36
|
def method_missing(method_name, *args, &block)
|
33
37
|
sub_calls = []
|
34
38
|
@calls << {
|
@@ -40,6 +44,15 @@ module HybridPlatformsConductor
|
|
40
44
|
DslParser.new(sub_calls)
|
41
45
|
end
|
42
46
|
|
47
|
+
# Make sure we register the methods we handle in method_missing
|
48
|
+
#
|
49
|
+
# Parameters::
|
50
|
+
# * *name* (Symbol): The missing method name
|
51
|
+
# * *include_private* (Boolean): Should we include private methods in the search?
|
52
|
+
def respond_to_missing?(_name, _include_private)
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
43
56
|
end
|
44
57
|
|
45
58
|
end
|
@@ -40,11 +40,14 @@ module HybridPlatformsConductor
|
|
40
40
|
add_recipe_in_tree(cookbook_dir, cookbook, recipe)
|
41
41
|
end
|
42
42
|
end
|
43
|
+
# Make sure we don't combine those 2 loops
|
44
|
+
# rubocop:disable Style/CombinableLoops
|
43
45
|
@platform.deployable_services.each do |service|
|
44
|
-
@platform.policy_run_list(service).each do |(
|
46
|
+
@platform.policy_run_list(service).each do |(_cookbook_dir, cookbook, recipe)|
|
45
47
|
mark_recipe_used_by_policy(cookbook, recipe, service)
|
46
48
|
end
|
47
49
|
end
|
50
|
+
# rubocop:enable Style/CombinableLoops
|
48
51
|
@recipes_tree
|
49
52
|
end
|
50
53
|
|
@@ -58,25 +61,25 @@ module HybridPlatformsConductor
|
|
58
61
|
# * *recipe* (Symbol): The recipe name
|
59
62
|
def add_recipe_in_tree(cookbook_dir, cookbook, recipe)
|
60
63
|
@recipes_tree[cookbook] = {} unless @recipes_tree.key?(cookbook)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@recipes_tree[cookbook][recipe] = recipe_info.merge(
|
75
|
-
used_by_policies: []
|
76
|
-
)
|
77
|
-
recipe_info[:included_recipes].each do |(sub_cookbook_dir, sub_cookbook, sub_recipe)|
|
78
|
-
add_recipe_in_tree(sub_cookbook_dir, sub_cookbook, sub_recipe)
|
64
|
+
return if @recipes_tree[cookbook].key?(recipe)
|
65
|
+
|
66
|
+
recipe_info =
|
67
|
+
if cookbook_dir.nil?
|
68
|
+
# This recipe comes from an external cookbook, we won't get into it.
|
69
|
+
{
|
70
|
+
included_recipes: [],
|
71
|
+
used_templates: [],
|
72
|
+
used_files: [],
|
73
|
+
used_cookbooks: []
|
74
|
+
}
|
75
|
+
else
|
76
|
+
recipe_usage(cookbook_dir, cookbook, recipe)
|
79
77
|
end
|
78
|
+
@recipes_tree[cookbook][recipe] = recipe_info.merge(
|
79
|
+
used_by_policies: []
|
80
|
+
)
|
81
|
+
recipe_info[:included_recipes].each do |(sub_cookbook_dir, sub_cookbook, sub_recipe)|
|
82
|
+
add_recipe_in_tree(sub_cookbook_dir, sub_cookbook, sub_recipe)
|
80
83
|
end
|
81
84
|
end
|
82
85
|
|
@@ -115,18 +118,18 @@ module HybridPlatformsConductor
|
|
115
118
|
recipe_content.
|
116
119
|
scan(/source\s+(["'])(.+?)\1/).
|
117
120
|
each do |(_sub_grp, source)|
|
118
|
-
sources << source unless source =~
|
121
|
+
sources << source unless source =~ %r{^https?://}
|
119
122
|
end
|
120
123
|
erb_sources = sources.select { |source| File.extname(source).downcase == '.erb' }
|
121
124
|
non_erb_sources = sources - erb_sources
|
122
125
|
erb_sources.concat(recipe_content.scan(/template:?\s+(["'])(.+?)\1/).map { |(_sub_grp, source)| source })
|
123
126
|
# Check for known resources and library methods
|
124
127
|
used_cookbooks = []
|
125
|
-
known_resources.each do |
|
126
|
-
used_cookbooks <<
|
128
|
+
known_resources.each do |itr_cookbook, methods|
|
129
|
+
used_cookbooks << itr_cookbook if methods.any? { |method_name| recipe_content.include?(method_name) }
|
127
130
|
end
|
128
|
-
known_library_methods.each do |
|
129
|
-
used_cookbooks <<
|
131
|
+
known_library_methods.each do |itr_cookbook, methods|
|
132
|
+
used_cookbooks << itr_cookbook if methods.any? { |method_name| recipe_content.include?(method_name) }
|
130
133
|
end
|
131
134
|
{
|
132
135
|
included_recipes: used_recipes,
|
@@ -171,9 +174,9 @@ module HybridPlatformsConductor
|
|
171
174
|
@known_library_methods = {}
|
172
175
|
for_each_cookbook do |cookbook, cookbook_dir|
|
173
176
|
if File.exist?("#{cookbook_dir}/libraries")
|
174
|
-
found_methods =
|
175
|
-
|
176
|
-
|
177
|
+
found_methods = Dir.glob("#{cookbook_dir}/libraries/*.rb").
|
178
|
+
map { |lib_file| File.read(lib_file).scan(/\bdef\s+(\w+)\b/).map { |(method_name)| method_name } }.
|
179
|
+
flatten - INVALID_LIBRARY_METHODS
|
177
180
|
@known_library_methods[cookbook] = found_methods unless found_methods.empty?
|
178
181
|
end
|
179
182
|
end
|
@@ -184,15 +187,13 @@ module HybridPlatformsConductor
|
|
184
187
|
# Iterate over all cookbooks
|
185
188
|
#
|
186
189
|
# Parameters::
|
187
|
-
# * Proc: Code called for each cookbook:
|
190
|
+
# * *block* (Proc): Code called for each cookbook:
|
188
191
|
# * Parameters::
|
189
192
|
# * *cookbook* (Symbol): Cookbook name
|
190
193
|
# * *cookbook_dir* (String): Cookbook directory
|
191
|
-
def for_each_cookbook
|
194
|
+
def for_each_cookbook(&block)
|
192
195
|
@platform.known_cookbook_paths.each do |cookbook_path|
|
193
|
-
cookbooks_in(cookbook_path).each
|
194
|
-
yield cookbook, cookbook_dir
|
195
|
-
end
|
196
|
+
cookbooks_in(cookbook_path).each(&block)
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
@@ -203,7 +204,7 @@ module HybridPlatformsConductor
|
|
203
204
|
# Result::
|
204
205
|
# * Hash<Symbol, String>: List of cookbook directories, per cookbook name
|
205
206
|
def cookbooks_in(cookbook_type)
|
206
|
-
|
207
|
+
Dir.glob("#{@platform.repository_path}/#{cookbook_type}/*").map { |dir| [File.basename(dir).to_sym, dir] }.sort.to_h
|
207
208
|
end
|
208
209
|
|
209
210
|
# Mark a recipe (and its included recipes) as used by a policy
|
@@ -213,11 +214,11 @@ module HybridPlatformsConductor
|
|
213
214
|
# * *recipe* (Symbol): The recipe
|
214
215
|
# * *used_by_policy* (String): The policy using this recipe
|
215
216
|
def mark_recipe_used_by_policy(cookbook, recipe, used_by_policy)
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
217
|
+
return if @recipes_tree[cookbook][recipe][:used_by_policies].include?(used_by_policy)
|
218
|
+
|
219
|
+
@recipes_tree[cookbook][recipe][:used_by_policies] << used_by_policy
|
220
|
+
@recipes_tree[cookbook][recipe][:included_recipes].each do |(_sub_cookbook_dir, sub_cookbook, sub_recipe)|
|
221
|
+
mark_recipe_used_by_policy(sub_cookbook, sub_recipe, used_by_policy)
|
221
222
|
end
|
222
223
|
end
|
223
224
|
|