hybrid_platforms_conductor 34.0.0 → 34.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/bin/get_impacted_nodes +1 -1
  4. data/docs/gen/mermaid/README.md-0.png +0 -0
  5. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  6. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  7. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  8. data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
  9. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  10. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  11. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  12. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  13. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  14. data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
  15. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  16. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  17. data/docs/tutorial/02_first_node.md +4 -4
  18. data/docs/tutorial/03_scale.md +4 -4
  19. data/docs/tutorial/05_extend_with_plugins.md +1 -0
  20. data/examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb +4 -4
  21. data/examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb +4 -4
  22. data/examples/tutorial/03_scale/my-service-conf-repo/service_web-hello.rb +4 -4
  23. data/examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb +4 -4
  24. data/examples/tutorial/04_test/my-service-conf-repo/service_web-hello.rb +4 -4
  25. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb +4 -4
  26. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_web-hello.rb +4 -4
  27. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/platform_handler/json_bash.rb +2 -2
  28. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/report/web_report.rb +1 -1
  29. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/my_hpc_plugins.gemspec +2 -1
  30. data/lib/hybrid_platforms_conductor/actions_executor.rb +2 -2
  31. data/lib/hybrid_platforms_conductor/cmd_runner.rb +4 -4
  32. data/lib/hybrid_platforms_conductor/config.rb +1 -0
  33. data/lib/hybrid_platforms_conductor/core_extensions/bundler/without_bundled_env.rb +2 -2
  34. data/lib/hybrid_platforms_conductor/core_extensions/secret_string/colorize.rb +18 -0
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +13 -13
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +3 -3
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +3 -4
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +13 -13
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +6 -1
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +1 -1
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +2 -2
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +5 -5
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +1 -1
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +1 -1
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +1 -1
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/test/can_be_checked.rb +1 -1
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +5 -1
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +5 -1
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +1 -1
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +2 -2
  51. data/lib/hybrid_platforms_conductor/json_dumper.rb +1 -1
  52. data/lib/hybrid_platforms_conductor/logger_helpers.rb +2 -18
  53. data/lib/hybrid_platforms_conductor/nodes_handler.rb +4 -4
  54. data/lib/hybrid_platforms_conductor/parallel_threads.rb +2 -2
  55. data/lib/hybrid_platforms_conductor/platform_handler.rb +1 -1
  56. data/lib/hybrid_platforms_conductor/plugins.rb +2 -2
  57. data/lib/hybrid_platforms_conductor/provisioner.rb +1 -1
  58. data/lib/hybrid_platforms_conductor/test.rb +1 -1
  59. data/lib/hybrid_platforms_conductor/tests_runner.rb +2 -3
  60. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +3 -3
  61. data/lib/hybrid_platforms_conductor/topographer.rb +1 -1
  62. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  63. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +2 -2
  64. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +2 -2
  65. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +18 -1
  66. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +2 -2
  67. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +2 -2
  68. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +2 -2
  69. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +2 -2
  70. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +2 -2
  71. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +6 -1
  72. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +1 -1
  73. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +2 -2
  74. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +1 -1
  75. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +2 -2
  76. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +2 -2
  77. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +3 -3
  78. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +1 -1
  79. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +2 -2
  80. data/spec/hybrid_platforms_conductor_test/executables/check_node_spec.rb +3 -3
  81. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +3 -3
  82. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +2 -2
  83. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +2 -2
  84. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +2 -2
  85. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +2 -2
  86. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +2 -2
  87. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +2 -2
  88. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +2 -2
  89. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +2 -2
  90. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +2 -2
  91. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +17 -17
  92. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +4 -4
  93. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +2 -2
  94. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +1 -1
  95. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +30 -2
  96. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +4 -4
  97. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +1 -9
  98. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +1 -1
  99. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +3 -3
  100. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +2 -1
  101. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb +1 -2
  102. data/spec/spec_helper.rb +14 -0
  103. data/tools/generate_mermaid +1 -1
  104. metadata +34 -19
@@ -69,7 +69,7 @@ module HybridPlatformsConductor
69
69
  expected_match.nil? ? 'unreadable' : expected_match[1]
70
70
  end
71
71
  log_debug "Current Chef version: #{existing_version}. Required version: #{required_version}"
72
- @cmd_runner.run_cmd "curl -L https://omnitruck.chef.io/install.sh | #{@cmd_runner.root? ? '' : 'sudo '}bash -s -- -P chef-workstation -v #{required_version}" unless existing_version == required_version
72
+ @cmd_runner.run_cmd "curl -L https://omnitruck.chef.io/install.sh | #{'sudo ' unless @cmd_runner.root?}bash -s -- -P chef-workstation -v #{required_version}" unless existing_version == required_version
73
73
  end
74
74
 
75
75
  # Get the list of known nodes.
@@ -160,7 +160,7 @@ module HybridPlatformsConductor
160
160
  @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}")
161
161
  extra_cp_data_bags = File.exist?("#{@repository_path}/data_bags") ? " && cp -ar data_bags/ #{package_dir}/" : ''
162
162
  @cmd_runner.run_cmd "cd #{@repository_path} && \
163
- #{@cmd_runner.root? ? '' : 'sudo '}rm -rf #{package_dir} && \
163
+ #{'sudo ' unless @cmd_runner.root?}rm -rf #{package_dir} && \
164
164
  /opt/chef-workstation/bin/chef export #{policy_file} #{package_dir} --chef-license accept#{extra_cp_data_bags}"
165
165
  next if @cmd_runner.dry_run
166
166
 
@@ -468,17 +468,17 @@ module HybridPlatformsConductor
468
468
  unless defined?(@cookbook_paths)
469
469
  config_file = "#{@repository_path}/config.rb"
470
470
  @cookbook_paths = (
471
- ['cookbooks'] +
472
- if File.exist?(config_file)
473
- # Read the knife configuration to get cookbook paths
474
- dsl_parser = DslParser.new
475
- dsl_parser.parse(config_file)
476
- cookbook_path_call = dsl_parser.calls.find { |call_info| call_info[:method] == :cookbook_path }
477
- cookbook_path_call.nil? ? [] : cookbook_path_call[:args].first
478
- else
479
- []
480
- end
481
- ).
471
+ ['cookbooks'] +
472
+ if File.exist?(config_file)
473
+ # Read the knife configuration to get cookbook paths
474
+ dsl_parser = DslParser.new
475
+ dsl_parser.parse(config_file)
476
+ cookbook_path_call = dsl_parser.calls.find { |call_info| call_info[:method] == :cookbook_path }
477
+ cookbook_path_call.nil? ? [] : cookbook_path_call[:args].first
478
+ else
479
+ []
480
+ end
481
+ ).
482
482
  map do |dir|
483
483
  # Only keep dirs that actually exist and are part of our repository
484
484
  full_path = dir.start_with?('/') ? dir : File.expand_path("#{@repository_path}/#{dir}")
@@ -134,7 +134,12 @@ module HybridPlatformsConductor
134
134
  # cf https://github.com/moby/moby/issues/2801
135
135
  # Make sure we refresh its info before querying it, as we could hit a cache of a previous IP.
136
136
  @container.refresh!
137
- @container.json['NetworkSettings']['IPAddress']
137
+ network_settings = @container.json['NetworkSettings'] || {}
138
+ # Recent Docker versions don't fill the legacy 'IPAddress' field anymore: the IP is stored per network.
139
+ [
140
+ network_settings['IPAddress'],
141
+ *network_settings.fetch('Networks', {}).values.map { |network| network['IPAddress'] }
142
+ ].find { |network_ip| !network_ip.to_s.empty? }
138
143
  end
139
144
 
140
145
  end
@@ -110,7 +110,7 @@ module HybridPlatformsConductor
110
110
  # Result::
111
111
  # * String: The Podman command
112
112
  def podman_cmd
113
- @podman_cmd = "#{@cmd_runner.root? ? '' : 'sudo '}podman" unless defined?(@podman_cmd)
113
+ @podman_cmd = "#{'sudo ' unless @cmd_runner.root?}podman" unless defined?(@podman_cmd)
114
114
  @podman_cmd
115
115
  end
116
116
 
@@ -499,7 +499,7 @@ class ProxmoxWaiter
499
499
  if hpc_marker_idx.nil?
500
500
  {}
501
501
  else
502
- vm_description_lines[hpc_marker_idx + 1..].to_h do |line|
502
+ vm_description_lines[(hpc_marker_idx + 1)..].to_h do |line|
503
503
  property, value = line.split(': ')
504
504
  [property.to_sym, value]
505
505
  end
@@ -654,7 +654,7 @@ class ProxmoxWaiter
654
654
  # * String: The task status
655
655
  def task_status(pve_node, task)
656
656
  status_info = @proxmox.get("nodes/#{pve_node}/tasks/#{task}/status")
657
- "#{status_info['status']}#{status_info['exitstatus'] ? ":#{status_info['exitstatus']}" : ''}"
657
+ "#{status_info['status']}#{":#{status_info['exitstatus']}" if status_info['exitstatus']}"
658
658
  end
659
659
 
660
660
  # Get a path from the API it returns its JSON result.
@@ -101,7 +101,7 @@ module HybridPlatformsConductor
101
101
 
102
102
  # Get the HPC info associated to this VM
103
103
  # Hash<Symbol,String>
104
- vm_hpc_info = vm_description_lines[hpc_marker_idx + 1..].to_h do |line|
104
+ vm_hpc_info = vm_description_lines[(hpc_marker_idx + 1)..].to_h do |line|
105
105
  property, value = line.split(': ')
106
106
  [property.to_sym, value]
107
107
  end
@@ -161,7 +161,7 @@ module HybridPlatformsConductor
161
161
  # In the end the hostname looks like:
162
162
  # <truncated_node_environment>.<unique_id>.hpc-test.com
163
163
  hostname = "-#{Digest::MD5.hexdigest(hostname)[0..7]}.hpc-test.com"
164
- hostname = "#{@node}.#{@environment}"[0..MAX_PROXMOX_HOSTNAME_SIZE - hostname.size - 1] + hostname
164
+ hostname = "#{@node}.#{@environment}"[0..(MAX_PROXMOX_HOSTNAME_SIZE - hostname.size - 1)] + hostname
165
165
  end
166
166
  @lxc_details = request_lxc_creation_for(
167
167
  ostemplate: pve_template,
@@ -390,7 +390,7 @@ module HybridPlatformsConductor
390
390
  # * String: The task status
391
391
  def task_status(proxmox, pve_node, task)
392
392
  status_info = proxmox_get(proxmox, "nodes/#{pve_node}/tasks/#{task}/status")
393
- "#{status_info['status']}#{status_info['exitstatus'] ? ":#{status_info['exitstatus']}" : ''}"
393
+ "#{status_info['status']}#{":#{status_info['exitstatus']}" if status_info['exitstatus']}"
394
394
  end
395
395
 
396
396
  # Execute a command on the sync node and get back its JSON result
@@ -450,7 +450,7 @@ module HybridPlatformsConductor
450
450
  )[proxmox_test_info[:sync_node]]
451
451
  end
452
452
  stdout_lines = stdout.split("\n")
453
- result = JSON.parse(stdout_lines[stdout_lines.index('===== JSON =====') + 1..].join("\n")).transform_keys(&:to_sym)
453
+ result = JSON.parse(stdout_lines[(stdout_lines.index('===== JSON =====') + 1)..].join("\n")).transform_keys(&:to_sym)
454
454
  raise "[ #{@node}/#{@environment} ] - Error returned by #{cmd}: #{result[:error]}" if result.key?(:error)
455
455
  ensure
456
456
  File.unlink(config_file)
@@ -530,7 +530,7 @@ module HybridPlatformsConductor
530
530
  if result.size > MAX_FILE_ID_SIZE
531
531
  # Truncate it, but add a unique ID in it.
532
532
  result = "-#{Digest::MD5.hexdigest(result)[0..7]}"
533
- result = "#{@node}_#{@environment}"[0..MAX_FILE_ID_SIZE - result.size - 1] + result
533
+ result = "#{@node}_#{@environment}"[0..(MAX_FILE_ID_SIZE - result.size - 1)] + result
534
534
  end
535
535
  result
536
536
  end
@@ -116,7 +116,7 @@ module HybridPlatformsConductor
116
116
  nodes_for_ip_range.
117
117
  sort_by { |node_info| node_info[:node] }.
118
118
  each do |node_info|
119
- output << "* '''#{node_info.delete(:node)}'''#{node_info[:private_ips].nil? || node_info[:private_ips].empty? ? '' : " - #{node_info[:private_ips].first}"} - #{node_info.delete(:description)}\n"
119
+ output << "* '''#{node_info.delete(:node)}'''#{" - #{node_info[:private_ips].first}" unless node_info[:private_ips].nil? || node_info[:private_ips].empty?} - #{node_info.delete(:description)}\n"
120
120
  node_info.delete(:private_ips) if !node_info[:private_ips].nil? && node_info[:private_ips].size == 1
121
121
  node_info.sort.each do |property, value|
122
122
  next if value.nil?
@@ -102,7 +102,7 @@ module HybridPlatformsConductor
102
102
  end
103
103
  end
104
104
  conflicting_path = safe_merge(secrets, @secrets[secret_id])
105
- raise "Secret set at path #{conflicting_path.join('->')} by #{keepass_secrets_info[:database]}#{keepass_secrets_info[:group_path].empty? ? '' : " from group #{keepass_secrets_info[:group_path].join('/')}"} for service #{service} on node #{node} has conflicting values (#{log_debug? ? "#{@secrets[secret_id].dig(*conflicting_path)} != #{secrets.dig(*conflicting_path)}" : 'set debug for value details'})." unless conflicting_path.nil?
105
+ raise "Secret set at path #{conflicting_path.join('->')} by #{keepass_secrets_info[:database]}#{" from group #{keepass_secrets_info[:group_path].join('/')}" unless keepass_secrets_info[:group_path].empty?} for service #{service} on node #{node} has conflicting values (#{log_debug? ? "#{@secrets[secret_id].dig(*conflicting_path)} != #{secrets.dig(*conflicting_path)}" : 'set debug for value details'})." unless conflicting_path.nil?
106
106
  end
107
107
  secrets
108
108
  end
@@ -120,7 +120,7 @@ module HybridPlatformsConductor
120
120
  assert_equal(
121
121
  reviewers_found,
122
122
  true,
123
- "[#{repo_id}] - Missing mandatory reviewers among #{mandatory_default_reviewers.join(', ')}#{required_approvers.nil? ? '' : " with a minimum of #{required_approvers} approvals"} from any branch to any branch"
123
+ "[#{repo_id}] - Missing mandatory reviewers among #{mandatory_default_reviewers.join(', ')}#{" with a minimum of #{required_approvers} approvals" unless required_approvers.nil?} from any branch to any branch"
124
124
  )
125
125
  end
126
126
  # Make sure the repository has master being tagged correctly
@@ -9,7 +9,7 @@ module HybridPlatformsConductor
9
9
 
10
10
  # Check my_test_plugin.rb.sample documentation for signature details.
11
11
  def test_on_check_node(stdout, stderr, exit_status)
12
- assert_equal exit_status, 0, "Check-node run returned error #{exit_status}#{log_debug? ? ":\n===== STDOUT =====\n#{stdout}===== STDERR =====#{stderr}" : ''}"
12
+ assert_equal exit_status, 0, "Check-node run returned error #{exit_status}#{":\n===== STDOUT =====\n#{stdout}===== STDERR =====#{stderr}" if log_debug?}"
13
13
  end
14
14
 
15
15
  end
@@ -24,6 +24,8 @@ module HybridPlatformsConductor
24
24
  def test_for_node
25
25
  @deployer.with_test_provisioned_instance(@config.tests_provisioner_id, @node, environment: 'check_deploy_and_idempotence', reuse_instance: log_debug?) do |deployer, instance|
26
26
  # Check that we can connect with root
27
+ # non_interactive makes net-ssh fail instead of prompting for a password when authentication fails.
28
+ # Prompting would raise Errno::ENOTTY when there is no TTY to prompt on (for example in CI).
27
29
  ssh_ok = false
28
30
  begin
29
31
  Net::SSH.start(
@@ -31,7 +33,8 @@ module HybridPlatformsConductor
31
33
  'root',
32
34
  password: 'root_pwd',
33
35
  auth_methods: ['password'],
34
- verify_host_key: :never
36
+ verify_host_key: :never,
37
+ non_interactive: true
35
38
  ) do |ssh|
36
39
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
37
40
  end
@@ -73,6 +76,7 @@ module HybridPlatformsConductor
73
76
  password: 'root_pwd',
74
77
  auth_methods: ['password'],
75
78
  verify_host_key: :never,
79
+ non_interactive: true,
76
80
  port: ssh_port
77
81
  ) do |ssh|
78
82
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
@@ -16,6 +16,8 @@ module HybridPlatformsConductor
16
16
 
17
17
  @deployer.with_test_provisioned_instance(@config.tests_provisioner_id, @node, environment: 'deploy_removes_root_access', reuse_instance: log_debug?) do |deployer, instance|
18
18
  # Check that we can connect with root
19
+ # non_interactive makes net-ssh fail instead of prompting for a password when authentication fails.
20
+ # Prompting would raise Errno::ENOTTY when there is no TTY to prompt on (for example in CI).
19
21
  ssh_ok = false
20
22
  begin
21
23
  Net::SSH.start(
@@ -23,7 +25,8 @@ module HybridPlatformsConductor
23
25
  'root',
24
26
  password: 'root_pwd',
25
27
  auth_methods: ['password'],
26
- verify_host_key: :never
28
+ verify_host_key: :never,
29
+ non_interactive: true
27
30
  ) do |ssh|
28
31
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
29
32
  end
@@ -51,6 +54,7 @@ module HybridPlatformsConductor
51
54
  password: 'root_pwd',
52
55
  auth_methods: ['password'],
53
56
  verify_host_key: :never,
57
+ non_interactive: true,
54
58
  port: ssh_port
55
59
  ) do |ssh|
56
60
  ssh_ok = ssh.exec!('echo Works').strip == 'Works'
@@ -16,7 +16,7 @@ module HybridPlatformsConductor
16
16
  # Flatten the paths rules so that we can spot inconsistencies in configuration
17
17
  @config.aggregate_files_rules(@nodes_handler, @node, file_system_type: :hdfs).to_h do |path, rule_info|
18
18
  [
19
- "if sudo#{rule_info[:context][:sudo_user] ? " -u #{rule_info[:context][:sudo_user]}" : ''} hdfs dfs -ls \"#{path}\" ; then echo 1 ; else echo 0 ; fi",
19
+ "if sudo#{" -u #{rule_info[:context][:sudo_user]}" if rule_info[:context][:sudo_user]} hdfs dfs -ls \"#{path}\" ; then echo 1 ; else echo 0 ; fi",
20
20
  {
21
21
  validator: proc do |stdout, stderr|
22
22
  case stdout.last
@@ -48,7 +48,7 @@ module HybridPlatformsConductor
48
48
  # Follow the last link recursively until we find a .xml or compressed file
49
49
  current_url = artifactory_url
50
50
  loop do
51
- current_url = "#{current_url}#{current_url.end_with?('/') ? '' : '/'}#{Nokogiri::HTML.parse(URI.parse(current_url).open).css('a').last['href']}"
51
+ current_url = "#{current_url}#{'/' unless current_url.end_with?('/')}#{Nokogiri::HTML.parse(URI.parse(current_url).open).css('a').last['href']}"
52
52
  break if current_url.end_with?('.xml') || KNOWN_COMPRESSIONS.keys.any? { |file_ext| current_url.end_with?(".#{file_ext}") }
53
53
 
54
54
  log_debug "Follow last link to #{current_url}"
@@ -120,7 +120,7 @@ module HybridPlatformsConductor
120
120
  if idx_results.nil?
121
121
  error 'No results given by the oscap run', stdout.join("\n")
122
122
  else
123
- results = Nokogiri::XML(stdout[idx_results + 1..].join("\n"))
123
+ results = Nokogiri::XML(stdout[(idx_results + 1)..].join("\n"))
124
124
  results.remove_namespaces!
125
125
  oval_definitions = results.css('oval_results oval_definitions definitions definition')
126
126
  results.css('results system definitions definition').each do |definition_xml|
@@ -74,7 +74,7 @@ module HybridPlatformsConductor
74
74
  out "[ #{node} ] - Error while dumping JSON. Check #{stdout_file_name}"
75
75
  else
76
76
  json_file_name = "#{@dump_dir}/#{node}.json"
77
- File.write(json_file_name, stdout[dump_begin_idx + 1..dump_end_idx - 1].join("\n"))
77
+ File.write(json_file_name, stdout[(dump_begin_idx + 1)..(dump_end_idx - 1)].join("\n"))
78
78
  out "[ #{node} ] - OK. Check #{json_file_name}"
79
79
  end
80
80
  else
@@ -1,23 +1,7 @@
1
1
  require 'colorize'
2
2
  require 'logger'
3
3
  require 'ruby-progressbar'
4
- require 'secret_string'
5
-
6
- # Add colorization methods to SecretString, but always directed to the silenced string as we NEVER want to modiy/clone a secret
7
- class SecretString
8
-
9
- extend Colorize::ClassMethods
10
-
11
- def_delegators :@silenced_str, *%i[
12
- colorize
13
- uncolorize
14
- colorized?
15
- ]
16
-
17
- color_methods
18
- modes_methods
19
-
20
- end
4
+ require 'hybrid_platforms_conductor/core_extensions/secret_string/colorize'
21
5
 
22
6
  module HybridPlatformsConductor
23
7
 
@@ -288,7 +272,7 @@ module HybridPlatformsConductor
288
272
  output: stdout_log_device.is_a?(ProgressBarLogDevice) ? $stdout : stdout_log_device,
289
273
  title: 'Initializing...',
290
274
  total: nbr_total,
291
- format: "#{name ? "#{name} " : ''}[%j%%] - |%bC%i| - [ %t ]",
275
+ format: "#{"#{name} " if name}[%j%%] - |%bC%i| - [ %t ]",
292
276
  progress_mark: ' ',
293
277
  remainder_mark: '-'
294
278
  )
@@ -506,8 +506,8 @@ module HybridPlatformsConductor
506
506
  # * *block* (Proc): The code called for each node being iterated on.
507
507
  # * Parameters::
508
508
  # * *node* (String): The node name
509
- def for_each_node_in(nodes, parallel: false, nbr_threads_max: nil, progress: 'Processing nodes', &block)
510
- for_each_element_in(nodes.sort, parallel: parallel, nbr_threads_max: nbr_threads_max, progress: progress, &block)
509
+ def for_each_node_in(nodes, parallel: false, nbr_threads_max: nil, progress: 'Processing nodes', &)
510
+ for_each_element_in(nodes.sort, parallel: parallel, nbr_threads_max: nbr_threads_max, progress: progress, &)
511
511
  end
512
512
 
513
513
  # Get the list of impacted nodes from a git diff on a platform
@@ -527,7 +527,7 @@ module HybridPlatformsConductor
527
527
  raise "Unkown platform #{platform_name}. Possible platforms are #{@platforms_handler.known_platforms.map(&:name).sort.join(', ')}" if platform.nil?
528
528
 
529
529
  begin
530
- _exit_status, stdout, _stderr = @cmd_runner.run_cmd "cd #{platform.repository_path} && git --no-pager diff --no-color #{from_commit} #{to_commit.nil? ? '' : to_commit}", log_to_stdout: log_debug?
530
+ _exit_status, stdout, _stderr = @cmd_runner.run_cmd "cd #{platform.repository_path} && git --no-pager diff --no-color #{from_commit} #{to_commit unless to_commit.nil?}", log_to_stdout: log_debug?
531
531
  rescue CmdRunner::UnexpectedExitCodeError
532
532
  raise GitError, $ERROR_INFO.to_s
533
533
  end
@@ -549,7 +549,7 @@ module HybridPlatformsConductor
549
549
  current_file_diff[:moved_to] = to unless from == to
550
550
  files_diffs[from] = current_file_diff
551
551
  else
552
- current_file_diff[:diff] << "#{current_file_diff[:diff].empty? ? '' : "\n"}#{line}" unless current_file_diff.nil?
552
+ current_file_diff[:diff] << "#{"\n" unless current_file_diff[:diff].empty?}#{line}" unless current_file_diff.nil?
553
553
  end
554
554
  end
555
555
  impacted_nodes, impacted_services, impact_global = platform.impacts_from files_diffs
@@ -15,7 +15,7 @@ module HybridPlatformsConductor
15
15
  # * *block* (Proc): The code called for each node being iterated on.
16
16
  # * Parameters::
17
17
  # * *element* (Object): The object
18
- def for_each_element_in(list, parallel: false, nbr_threads_max: nil, progress: 'Process', &block)
18
+ def for_each_element_in(list, parallel: false, nbr_threads_max: nil, progress: 'Process', &)
19
19
  if parallel
20
20
  # Threads to wait for
21
21
  threads_to_join = []
@@ -84,7 +84,7 @@ module HybridPlatformsConductor
84
84
  threads_to_join.each(&:join)
85
85
  else
86
86
  # Execute synchronously
87
- list.each(&block)
87
+ list.each(&)
88
88
  end
89
89
  end
90
90
 
@@ -23,7 +23,7 @@ module HybridPlatformsConductor
23
23
  path
24
24
  elsif !git.nil?
25
25
  # Clone in a local repository
26
- local_repository_path = "#{@git_platforms_dir}/#{name.nil? ? File.basename(git)[0..-File.extname(git).size - 1] : name}"
26
+ local_repository_path = "#{@git_platforms_dir}/#{name.nil? ? File.basename(git)[0..(-File.extname(git).size - 1)] : name}"
27
27
  unless File.exist?(local_repository_path)
28
28
  branch = "refs/heads/#{branch}" unless branch.include?('/')
29
29
  local_ref = "refs/remotes/origin/#{branch.split('/').last}"
@@ -35,6 +35,7 @@ module HybridPlatformsConductor
35
35
 
36
36
  # Make an API similar to a Hash, delegated to @plugins
37
37
  extend Forwardable
38
+
38
39
  def_delegators :@plugins, *%i[
39
40
  []
40
41
  each
@@ -95,12 +96,11 @@ module HybridPlatformsConductor
95
96
  # * inherit from the base plugin class,
96
97
  # * have no descendants
97
98
  # Careful: !(class_1 < class_2) != (class_1 >= class_2), so disable the cop here for inversions.
98
- # rubocop:disable Style/InverseMethods
99
+ # rubocop:disable-next Style/InverseMethods
99
100
  if !klass.name.nil? && klass < ancestor_class && ObjectSpace.each_object(Class).all? { |other_klass| other_klass.name.nil? || !(other_klass < klass) }
100
101
  plugin_id = klass.name.split('::').last.gsub(/([a-z\d])([A-Z\d])/, '\1_\2').downcase.to_sym
101
102
  self[plugin_id] = klass
102
103
  end
103
- # rubocop:enable Style/InverseMethods
104
104
  end
105
105
  end
106
106
 
@@ -161,7 +161,7 @@ module HybridPlatformsConductor
161
161
  remaining_timeout -= Time.now - start_time
162
162
  break if remaining_timeout <= 0
163
163
  end
164
- log_debug "[ #{@node}/#{@environment} ] - #{instance_ip}:#{port} is#{port_listening ? '' : ' not'} opened."
164
+ log_debug "[ #{@node}/#{@environment} ] - #{instance_ip}:#{port} is#{' not' unless port_listening} opened."
165
165
  port_listening
166
166
  end
167
167
 
@@ -117,7 +117,7 @@ module HybridPlatformsConductor
117
117
  # * *message* (String): The error message
118
118
  # * *details* (String or nil): Additional details, or nil if none [default = nil]
119
119
  def error(message, details = nil)
120
- log_error "[ #{self} ] - #{message}#{details.nil? ? '' : "\n#{details}"}" if @expected_failure.nil?
120
+ log_error "[ #{self} ] - #{message}#{"\n#{details}" unless details.nil?}" if @expected_failure.nil?
121
121
  @errors << message
122
122
  end
123
123
 
@@ -286,7 +286,7 @@ module HybridPlatformsConductor
286
286
  node: node,
287
287
  # Keep this else on purpose to show where global tests could have expected failures
288
288
  # rubocop:disable Style/EmptyElse
289
- # rubocop:disable Lint/DuplicateBranch
289
+ # rubocop:disable-next Lint/DuplicateBranch
290
290
  expected_failure: if ignore_expected_failure
291
291
  nil
292
292
  elsif !node.nil?
@@ -299,7 +299,6 @@ module HybridPlatformsConductor
299
299
  # Global test
300
300
  nil
301
301
  end
302
- # rubocop:enable Lint/DuplicateBranch
303
302
  # rubocop:enable Style/EmptyElse
304
303
  )
305
304
  end
@@ -545,7 +544,7 @@ module HybridPlatformsConductor
545
544
  rescue
546
545
  # If an exception occurred, make sure all concerned nodes are reporting the error
547
546
  nodes_to_test.each do |node|
548
- error "Error while checking check-node output: #{$ERROR_INFO}#{log_debug? ? "\n#{$ERROR_INFO.backtrace.join("\n")}" : ''}", node: node
547
+ error "Error while checking check-node output: #{$ERROR_INFO}#{"\n#{$ERROR_INFO.backtrace.join("\n")}" if log_debug?}", node: node
549
548
  end
550
549
  {}
551
550
  end
@@ -35,7 +35,7 @@ module HybridPlatformsConductor
35
35
  @topographer.nodes_graph.sort.each do |node_name, node_info|
36
36
  node_info[:connections].each do |connected_node_name, labels|
37
37
  link_label = labels.sort.join(', ')
38
- link_label = "#{link_label[0..@topographer.config[:max_link_label_length] - 1]}..." if link_label.size > @topographer.config[:max_link_label_length]
38
+ link_label = "#{link_label[0..(@topographer.config[:max_link_label_length] - 1)]}..." if link_label.size > @topographer.config[:max_link_label_length]
39
39
  link_options = {
40
40
  label: link_label
41
41
  }
@@ -57,7 +57,7 @@ module HybridPlatformsConductor
57
57
  description = @topographer.description_for(node_name)
58
58
  dot_name = dot_name_for(node_name)
59
59
  node_options = {
60
- label: "#{@topographer.title_for(node_name)}#{description.nil? ? '' : "\\n#{description}"}",
60
+ label: "#{@topographer.title_for(node_name)}#{"\\n#{description}" unless description.nil?}",
61
61
  color: color_for(node_name)
62
62
  }
63
63
  if @topographer.node_cluster?(node_name)
@@ -65,7 +65,7 @@ module HybridPlatformsConductor
65
65
  file.puts " subgraph \"#{dot_name}\" {\n#{node_options.map { |opt, val| " #{opt}=\"#{val}\";\n" }.join}"
66
66
  # Always define an anchor node per cluster, as it will serve for links to and from the cluster itself.
67
67
  anchor_node_options = {
68
- label: "#{@topographer.title_for(node_name)}#{description.nil? ? '' : "\\n#{description}"}",
68
+ label: "#{@topographer.title_for(node_name)}#{"\\n#{description}" unless description.nil?}",
69
69
  color: 'green'
70
70
  }
71
71
  file.puts " \"#{dot_name_for_link(node_name)}\" [ #{anchor_node_options.map { |opt, val| "#{opt}=\"#{val}\"" }.join(' ')} ];"
@@ -326,7 +326,7 @@ module HybridPlatformsConductor
326
326
  def ancestor_nodes(nodes_list)
327
327
  ancestor_nodes_list = []
328
328
  @nodes_graph.each do |node_name, node_info|
329
- ancestor_nodes_list << node_name if !nodes_list.include?(node_name) && (!(node_info[:connections].keys & nodes_list).empty? || !(node_info[:includes] & nodes_list).empty?)
329
+ ancestor_nodes_list << node_name if !nodes_list.include?(node_name) && (!node_info[:connections].keys.intersect?(nodes_list).nil? || !node_info[:includes].intersect?(nodes_list).nil?)
330
330
  end
331
331
  if ancestor_nodes_list.empty?
332
332
  nodes_list
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '34.0.0'
3
+ VERSION = '34.0.1'
4
4
 
5
5
  end
@@ -8,8 +8,8 @@ describe HybridPlatformsConductor::ActionsExecutor do
8
8
  # * *block* (Proc): Code called with the environment ready
9
9
  # * Parameters::
10
10
  # * *repository* (String): Path to the repository
11
- def with_test_platform_for_actions(&block)
12
- with_test_platform_for_executor(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} }, &block)
11
+ def with_test_platform_for_actions(&)
12
+ with_test_platform_for_executor(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} }, &)
13
13
  end
14
14
 
15
15
  it 'executes a simple action on 1 node' do
@@ -8,14 +8,14 @@ describe HybridPlatformsConductor::ActionsExecutor do
8
8
  # * *block* (Proc): Code called with platform setup
9
9
  # * Parameters::
10
10
  # * *repository* (String): Repository where the platform has been setup
11
- def with_test_platform_for_connections(&block)
11
+ def with_test_platform_for_connections(&)
12
12
  with_test_platform_for_executor(
13
13
  nodes: {
14
14
  'node1' => {},
15
15
  'node2' => {},
16
16
  'node3' => {},
17
17
  'node4' => {}
18
- }, &block
18
+ }, &
19
19
  )
20
20
  end
21
21
 
@@ -4,6 +4,11 @@ describe HybridPlatformsConductor::ActionsExecutor do
4
4
 
5
5
  context 'when checking additional helpers' do
6
6
 
7
+ # The SSH version detected from the local installation must not influence the tests
8
+ before do
9
+ with_mocked_ssh_version
10
+ end
11
+
7
12
  # Return the connector to be tested
8
13
  #
9
14
  # Result::
@@ -40,7 +45,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
40
45
  /^\# \w+ - .+$/,
41
46
  /^\#+$/
42
47
  ]
43
- end_idx = ssh_config_lines[start_idx + 1..].index { |line| end_markers.any? { |end_marker| line =~ end_marker } }
48
+ end_idx = ssh_config_lines[(start_idx + 1)..].index { |line| end_markers.any? { |end_marker| line =~ end_marker } }
44
49
  end_idx = end_idx.nil? ? -1 : start_idx + end_idx
45
50
  "#{
46
51
  ssh_config_lines[start_idx..end_idx].select do |line|
@@ -133,6 +138,18 @@ describe HybridPlatformsConductor::ActionsExecutor do
133
138
  end
134
139
  end
135
140
 
141
+ it 'generates a global configuration when the installed OpenSSH version has several digits in its major version' do
142
+ # Mock an OpenSSH version whose major version has several digits (like OpenSSH 10 and beyond)
143
+ with_mocked_ssh_version "OpenSSH_10.0p2 Ubuntu-3ubuntu1, OpenSSL 3.5.1 1 Jul 2025\n"
144
+ with_test_platform({}) do
145
+ expect(ssh_config_for(nil)).to eq <<~EO_SSH_CONFIG
146
+ Host *
147
+ User test_user
148
+ ControlPath #{Dir.tmpdir}/hpc_ssh/hpc_ssh_mux_%h_%p_%r
149
+ EO_SSH_CONFIG
150
+ end
151
+ end
152
+
136
153
  it 'includes the gateway definition from environment' do
137
154
  with_test_platform({}, additional_config: 'gateway :gateway_1, \'Host my_gateway\'') do
138
155
  ENV['hpc_ssh_gateways_conf'] = 'gateway_1'
@@ -8,8 +8,8 @@ describe HybridPlatformsConductor::ActionsExecutor do
8
8
  # * *block* (Proc): Code called with the environment ready
9
9
  # * Parameters::
10
10
  # * *repository* (String): Path to the repository
11
- def with_test_platform_for_logging(&block)
12
- with_test_platform_for_executor(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} }, &block)
11
+ def with_test_platform_for_logging(&)
12
+ with_test_platform_for_executor(nodes: { 'node1' => {}, 'node2' => {}, 'node3' => {} }, &)
13
13
  end
14
14
 
15
15
  it 'captures stdout and stderr from action correctly' do
@@ -6,7 +6,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
6
6
  #
7
7
  # Parameters::
8
8
  # * *block* (Proc): Code called with platform setup
9
- def with_test_platform_for_parallel_tests(&block)
9
+ def with_test_platform_for_parallel_tests(&)
10
10
  with_test_platform_for_executor(
11
11
  nodes: {
12
12
  'node1' => {},
@@ -14,7 +14,7 @@ describe HybridPlatformsConductor::ActionsExecutor do
14
14
  'node3' => {},
15
15
  'node4' => {}
16
16
  },
17
- &block
17
+ &
18
18
  )
19
19
  end
20
20
 
@@ -6,8 +6,8 @@ describe HybridPlatformsConductor::ActionsExecutor do
6
6
  #
7
7
  # Parameters::
8
8
  # * *block* (Proc): Code called with platform setup
9
- def with_test_platform_for_timeouts_tests(&block)
10
- with_test_platform_for_executor(nodes: { 'node' => {} }, &block)
9
+ def with_test_platform_for_timeouts_tests(&)
10
+ with_test_platform_for_executor(nodes: { 'node' => {} }, &)
11
11
  end
12
12
 
13
13
  it 'executes an action without timeout' do
@@ -17,8 +17,8 @@ describe HybridPlatformsConductor::Deployer do
17
17
  # * *block* (Proc): Code called with the platform setup
18
18
  # * Parameters::
19
19
  # * *repository* (String): Platform's repository
20
- def with_test_platform_for_deploy_tests(platforms_info, as_git: false, additional_config: 'send_logs_to :test_log', &block)
21
- with_test_platform(platforms_info, as_git: as_git, additional_config: additional_config, &block)
20
+ def with_test_platform_for_deploy_tests(platforms_info, as_git: false, additional_config: 'send_logs_to :test_log', &)
21
+ with_test_platform(platforms_info, as_git: as_git, additional_config: additional_config, &)
22
22
  end
23
23
 
24
24
  it 'deploys correct logs information on 1 node' do
@@ -8,8 +8,8 @@ describe HybridPlatformsConductor::Deployer do
8
8
  #
9
9
  # Parameters::
10
10
  # * *block* (Proc): Code called with platform prepared
11
- def with_test_platform_for_remote_fs(&block)
12
- with_test_platform({ nodes: { 'node' => { services: %w[service1 service2] } } }, additional_config: 'send_logs_to :remote_fs', &block)
11
+ def with_test_platform_for_remote_fs(&)
12
+ with_test_platform({ nodes: { 'node' => { services: %w[service1 service2] } } }, additional_config: 'send_logs_to :remote_fs', &)
13
13
  end
14
14
 
15
15
  it 'returns actions to save logs' do