hybrid_platforms_conductor 33.9.5 → 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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +3 -1
  4. data/bin/free_veids +1 -1
  5. data/bin/get_impacted_nodes +1 -1
  6. data/bin/last_deploys +1 -1
  7. data/bin/nodes_to_deploy +3 -3
  8. data/docs/gen/mermaid/README.md-0.png +0 -0
  9. data/docs/gen/mermaid/docs/executables/check-node.md-0.png +0 -0
  10. data/docs/gen/mermaid/docs/executables/deploy.md-0.png +0 -0
  11. data/docs/gen/mermaid/docs/executables/free_ips.md-0.png +0 -0
  12. data/docs/gen/mermaid/docs/executables/free_veids.md-0.png +0 -0
  13. data/docs/gen/mermaid/docs/executables/get_impacted_nodes.md-0.png +0 -0
  14. data/docs/gen/mermaid/docs/executables/last_deploys.md-0.png +0 -0
  15. data/docs/gen/mermaid/docs/executables/nodes_to_deploy.md-0.png +0 -0
  16. data/docs/gen/mermaid/docs/executables/report.md-0.png +0 -0
  17. data/docs/gen/mermaid/docs/executables/run.md-0.png +0 -0
  18. data/docs/gen/mermaid/docs/executables/setup.md-0.png +0 -0
  19. data/docs/gen/mermaid/docs/executables/ssh_config.md-0.png +0 -0
  20. data/docs/gen/mermaid/docs/executables/test.md-0.png +0 -0
  21. data/docs/tutorial/02_first_node.md +4 -4
  22. data/docs/tutorial/03_scale.md +4 -4
  23. data/docs/tutorial/05_extend_with_plugins.md +1 -0
  24. data/examples/tutorial/02_first_node/my-service-conf-repo/service_my-service.rb +4 -4
  25. data/examples/tutorial/03_scale/my-service-conf-repo/service_my-service.rb +4 -4
  26. data/examples/tutorial/03_scale/my-service-conf-repo/service_web-hello.rb +4 -4
  27. data/examples/tutorial/04_test/my-service-conf-repo/service_my-service.rb +4 -4
  28. data/examples/tutorial/04_test/my-service-conf-repo/service_web-hello.rb +4 -4
  29. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_my-service.rb +4 -4
  30. data/examples/tutorial/05_extend_with_plugins/my-service-conf-repo/service_web-hello.rb +4 -4
  31. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/platform_handler/json_bash.rb +2 -2
  32. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/lib/my_hpc_plugins/hpc_plugins/report/web_report.rb +1 -1
  33. data/examples/tutorial/05_extend_with_plugins/my_hpc_plugins/my_hpc_plugins.gemspec +2 -1
  34. data/lib/hybrid_platforms_conductor/actions_executor.rb +2 -2
  35. data/lib/hybrid_platforms_conductor/cmd_runner.rb +4 -4
  36. data/lib/hybrid_platforms_conductor/config.rb +1 -0
  37. data/lib/hybrid_platforms_conductor/core_extensions/bundler/without_bundled_env.rb +3 -3
  38. data/lib/hybrid_platforms_conductor/core_extensions/cleanroom/fix_kwargs.rb +1 -0
  39. data/lib/hybrid_platforms_conductor/core_extensions/secret_string/colorize.rb +18 -0
  40. data/lib/hybrid_platforms_conductor/credentials.rb +1 -1
  41. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +3 -3
  42. data/lib/hybrid_platforms_conductor/deployer.rb +1 -1
  43. data/lib/hybrid_platforms_conductor/executable.rb +1 -1
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +2 -0
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -0
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +20 -18
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +3 -3
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +5 -5
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +13 -13
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +1 -1
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +6 -1
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +1 -1
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +3 -2
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +2 -2
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +6 -5
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +1 -0
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +1 -1
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/keepass.rb +4 -3
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +1 -1
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/can_be_checked.rb +1 -1
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +5 -1
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +5 -1
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +5 -5
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +1 -1
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +2 -2
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +1 -1
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +2 -2
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +1 -0
  69. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  70. data/lib/hybrid_platforms_conductor/logger_helpers.rb +8 -24
  71. data/lib/hybrid_platforms_conductor/nodes_handler.rb +8 -10
  72. data/lib/hybrid_platforms_conductor/parallel_threads.rb +3 -3
  73. data/lib/hybrid_platforms_conductor/platform_handler.rb +2 -2
  74. data/lib/hybrid_platforms_conductor/platforms_handler.rb +1 -1
  75. data/lib/hybrid_platforms_conductor/plugins.rb +2 -2
  76. data/lib/hybrid_platforms_conductor/provisioner.rb +1 -1
  77. data/lib/hybrid_platforms_conductor/services_handler.rb +6 -6
  78. data/lib/hybrid_platforms_conductor/test.rb +1 -1
  79. data/lib/hybrid_platforms_conductor/test_report.rb +4 -4
  80. data/lib/hybrid_platforms_conductor/tests_runner.rb +5 -3
  81. data/lib/hybrid_platforms_conductor/thycotic.rb +2 -2
  82. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +3 -3
  83. data/lib/hybrid_platforms_conductor/topographer.rb +3 -3
  84. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  85. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +2 -2
  86. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +2 -2
  87. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +3 -10
  88. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +19 -7
  89. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +2 -2
  90. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +2 -2
  91. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +2 -2
  92. data/spec/hybrid_platforms_conductor_test/api/credentials_spec.rb +13 -13
  93. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +2 -2
  94. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +2 -2
  95. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker/Dockerfile +1 -1
  96. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/docker_spec.rb +9 -4
  97. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +1 -1
  98. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +2 -2
  99. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/keepass_spec.rb +2 -2
  100. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +2 -2
  101. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +1 -1
  102. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +3 -3
  103. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +1 -1
  104. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +2 -2
  105. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +2 -2
  106. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +5 -5
  107. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +1 -1
  108. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +3 -3
  109. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +1 -3
  110. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +11 -11
  111. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +5 -5
  112. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +2 -2
  113. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +1 -1
  114. data/spec/hybrid_platforms_conductor_test/executables/check_node_spec.rb +3 -3
  115. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +3 -3
  116. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +2 -2
  117. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +2 -2
  118. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +2 -2
  119. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +2 -2
  120. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +2 -2
  121. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +3 -3
  122. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +2 -2
  123. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +2 -2
  124. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +2 -2
  125. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +17 -17
  126. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +4 -4
  127. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +2 -2
  128. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +1 -1
  129. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +33 -7
  130. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +7 -7
  131. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +2 -10
  132. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +1 -1
  133. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +7 -7
  134. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +2 -1
  135. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_3/recipes/35_unparsable_include.rb +3 -4
  136. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +1 -1
  137. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +1 -1
  138. data/spec/hybrid_platforms_conductor_test.rb +3 -2
  139. data/spec/spec_helper.rb +14 -0
  140. data/tools/generate_mermaid +1 -1
  141. metadata +185 -244
@@ -85,7 +85,7 @@ module HybridPlatformsConductor
85
85
  binding
86
86
  end
87
87
  variables.each do |var_name, var_value|
88
- erb_context.instance_variable_set("@#{var_name}".to_sym, var_value)
88
+ erb_context.instance_variable_set(:"@#{var_name}", var_value)
89
89
  end
90
90
  ERB.new(@gateways[gateway_conf]).result(erb_context.private_binding)
91
91
  end
@@ -131,8 +131,8 @@ module HybridPlatformsConductor
131
131
  # [API] - @nodes_handler can be used
132
132
  def init
133
133
  # Default values
134
- @ssh_user = ENV['hpc_ssh_user']
135
- @ssh_user = ENV['USER'] if @ssh_user.nil? || @ssh_user.empty?
134
+ @ssh_user = ENV.fetch('hpc_ssh_user', nil)
135
+ @ssh_user = ENV.fetch('USER', nil) if @ssh_user.nil? || @ssh_user.empty?
136
136
  if @ssh_user.nil? || @ssh_user.empty?
137
137
  _exit_status, stdout = @cmd_runner.run_cmd 'whoami', log_to_stdout: log_debug?
138
138
  @ssh_user = stdout.strip
@@ -141,7 +141,7 @@ module HybridPlatformsConductor
141
141
  @ssh_strict_host_key_checking = true
142
142
  @passwords = {}
143
143
  @auth_password = false
144
- @ssh_gateways_conf = ENV['hpc_ssh_gateways_conf'].nil? ? nil : ENV['hpc_ssh_gateways_conf'].to_sym
144
+ @ssh_gateways_conf = ENV['hpc_ssh_gateways_conf']&.to_sym
145
145
  @ssh_gateway_user = ENV['hpc_ssh_gateway_user'].nil? ? 'ubradm' : ENV['hpc_ssh_gateway_user']
146
146
  # The map of existing ssh directories that have been created, per node that can access them
147
147
  # Array< String, Array<String> >
@@ -218,8 +218,8 @@ module HybridPlatformsConductor
218
218
  # * *block* (Proc): Code called with the connections prepared.
219
219
  # * Parameters::
220
220
  # * *connected_nodes* (Array<String>): The list of connected nodes (should be equal to nodes unless no_exception == true and some nodes failed to connect)
221
- def with_connection_to(nodes, no_exception: false, &block)
222
- with_ssh_master_to(nodes, no_exception: no_exception, &block)
221
+ def with_connection_to(nodes, no_exception: false, &)
222
+ with_ssh_master_to(nodes, no_exception: no_exception, &)
223
223
  end
224
224
 
225
225
  # Integer: Max size for an argument that can be executed without getting through an intermediary file
@@ -328,18 +328,18 @@ module HybridPlatformsConductor
328
328
  --create \
329
329
  --gzip \
330
330
  --file - \
331
- #{owner.nil? ? '' : "--owner #{owner}"} \
332
- #{group.nil? ? '' : "--group #{group}"} \
331
+ #{"--owner #{owner}" unless owner.nil?} \
332
+ #{"--group #{group}" unless group.nil?} \
333
333
  #{File.basename(from)} | \
334
334
  #{ssh_exec} \
335
335
  #{ssh_url} \
336
- \"#{need_sudo ? @actions_executor.sudo_prefix(@node) : ''}tar \
336
+ "#{@actions_executor.sudo_prefix(@node) if need_sudo}tar \
337
337
  --extract \
338
338
  --gunzip \
339
339
  --file - \
340
340
  --directory #{to} \
341
341
  --owner root \
342
- \"
342
+ "
343
343
  EO_BASH
344
344
  end
345
345
  end
@@ -374,7 +374,7 @@ module HybridPlatformsConductor
374
374
  # GATEWAYS #
375
375
  ############
376
376
 
377
- #{@ssh_gateways_conf.nil? || !@config.known_gateways.include?(@ssh_gateways_conf) ? '' : @config.ssh_for_gateway(@ssh_gateways_conf, ssh_exec: ssh_exec, user: @ssh_user)}
377
+ #{@config.ssh_for_gateway(@ssh_gateways_conf, ssh_exec: ssh_exec, user: @ssh_user) unless @ssh_gateways_conf.nil? || !@config.known_gateways.include?(@ssh_gateways_conf)}
378
378
 
379
379
  #############
380
380
  # ENDPOINTS #
@@ -415,9 +415,9 @@ module HybridPlatformsConductor
415
415
  User #{@ssh_user}
416
416
  # Default control socket path to be used when multiplexing SSH connections
417
417
  ControlPath #{control_master_file('%h', '%p', '%r')}
418
- #{open_ssh_major_version >= 7 ? 'PubkeyAcceptedKeyTypes +ssh-dss' : ''}
419
- #{known_hosts_file.nil? ? '' : "UserKnownHostsFile #{known_hosts_file}"}
420
- #{@ssh_strict_host_key_checking ? '' : 'StrictHostKeyChecking no'}
418
+ #{'PubkeyAcceptedKeyTypes +ssh-dss' if open_ssh_major_version >= 7 && open_ssh_major_version < 9}
419
+ #{"UserKnownHostsFile #{known_hosts_file}" unless known_hosts_file.nil?}
420
+ #{'StrictHostKeyChecking no' unless @ssh_strict_host_key_checking}
421
421
 
422
422
  EO_SSH_CONFIG
423
423
  config_content
@@ -458,7 +458,7 @@ module HybridPlatformsConductor
458
458
  # Keep a cache of it.
459
459
  #
460
460
  # Result::
461
- # * String: The installed SSH major version
461
+ # * Integer: The installed SSH major version
462
462
  def open_ssh_major_version
463
463
  cache_filled = defined?(@open_ssh_major_version)
464
464
  unless cache_filled
@@ -468,7 +468,7 @@ module HybridPlatformsConductor
468
468
  log_debug 'Mock OpenSSH version because of dry-run mode'
469
469
  stdout = 'OpenSSH_7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u 20 Dec 2019'
470
470
  end
471
- @open_ssh_major_version = stdout.match(/^OpenSSH_(\d)\..+$/)[1].to_i
471
+ @open_ssh_major_version = stdout.match(/^OpenSSH_(\d+)\..+$/)[1].to_i
472
472
  end
473
473
  @open_ssh_major_version
474
474
  end
@@ -492,6 +492,8 @@ module HybridPlatformsConductor
492
492
  # Time in seconds to wait between different retries because system is booting up
493
493
  WAIT_TIME_FOR_BOOT = 10
494
494
 
495
+ private_constant :MAX_THREADS_CONTROL_MASTER, :MAX_RETRIES_FOR_BOOT, :WAIT_TIME_FOR_BOOT
496
+
495
497
  # Open an SSH control master to multiplex connections to a given list of nodes.
496
498
  # This method is re-entrant and reuses the same control masters.
497
499
  # It is multi-processes:
@@ -548,7 +550,7 @@ module HybridPlatformsConductor
548
550
  end
549
551
  else
550
552
  # Create the control master
551
- ssh_control_master_start_cmd = "#{ssh_exec}#{@passwords.key?(node) || @auth_password ? '' : ' -o BatchMode=yes'} -o ControlMaster=yes -o ControlPersist=yes #{ssh_url} true"
553
+ ssh_control_master_start_cmd = "#{ssh_exec}#{' -o BatchMode=yes' unless @passwords.key?(node) || @auth_password} -o ControlMaster=yes -o ControlPersist=yes #{ssh_url} true"
552
554
  idx_try = 0
553
555
  loop do
554
556
  exit_status, _stdout, stderr = @cmd_runner.run_cmd ssh_control_master_start_cmd, log_to_stdout: log_debug?, no_exception: true, timeout: timeout
@@ -714,7 +716,7 @@ module HybridPlatformsConductor
714
716
  # TODO: Make a mechanism that uses sshpass and the correct password only for the correct hostname (this requires parsing ssh parameters $*).
715
717
  # Current implementation is much simpler: it uses sshpass if at least 1 password is needed, and always uses the first password.
716
718
  # So far it is enough for our usage as we intend to use this only when deploying first time using root account, and all root accounts will have the same password.
717
- file.puts "#{@passwords.empty? ? '' : "sshpass -p#{@passwords.first[1]} "}ssh -F #{ssh_conf_file} $*"
719
+ file.puts "#{"sshpass -p#{@passwords.first[1]} " unless @passwords.empty?}ssh -F #{ssh_conf_file} $*"
718
720
  end
719
721
  File.write(ssh_conf_file, ssh_config(ssh_exec: ssh_exec_file, known_hosts_file: known_hosts_file, nodes: nodes))
720
722
  # Make sure all host keys are setup in the known hosts file
@@ -132,7 +132,7 @@ module HybridPlatformsConductor
132
132
  stdout_idx = stdout_lines.index(MARKER_STDOUT)
133
133
  stderr_idx = stdout_lines.index(MARKER_STDERR)
134
134
  deploy_info = {}
135
- stdout_lines[0..stdout_idx - 1].each do |line|
135
+ stdout_lines[0..(stdout_idx - 1)].each do |line|
136
136
  if line =~ /^([^:]+): (.+)$/
137
137
  key_str = Regexp.last_match(1)
138
138
  value = Regexp.last_match(2)
@@ -166,8 +166,8 @@ module HybridPlatformsConductor
166
166
  services: services,
167
167
  deployment_info: deploy_info,
168
168
  exit_status: exit_status =~ /^\d+$/ ? Integer(exit_status) : exit_status.to_sym,
169
- stdout: stdout_lines[stdout_idx + 1..stderr_idx - 1].join("\n"),
170
- stderr: stdout_lines[stderr_idx + 1..].join("\n")
169
+ stdout: stdout_lines[(stdout_idx + 1)..(stderr_idx - 1)].join("\n"),
170
+ stderr: stdout_lines[(stderr_idx + 1)..].join("\n")
171
171
  }
172
172
  end
173
173
  end
@@ -41,13 +41,12 @@ module HybridPlatformsConductor
41
41
  end
42
42
  end
43
43
  # Make sure we don't combine those 2 loops
44
- # rubocop:disable Style/CombinableLoops
44
+ # rubocop:disable-next Style/CombinableLoops
45
45
  @platform.deployable_services.each do |service|
46
46
  @platform.policy_run_list(service).each do |(_cookbook_dir, cookbook, recipe)|
47
47
  mark_recipe_used_by_policy(cookbook, recipe, service)
48
48
  end
49
49
  end
50
- # rubocop:enable Style/CombinableLoops
51
50
  @recipes_tree
52
51
  end
53
52
 
@@ -160,7 +159,7 @@ module HybridPlatformsConductor
160
159
  flatten(1)
161
160
  # Check for some helpers we know include some recipes
162
161
  @config.known_helpers_including_recipes.each do |helper_name, used_recipes_by_helper|
163
- if recipe_content =~ Regexp.new(/(\W|^)#{Regexp.escape(helper_name)}(\W|$)/)
162
+ if recipe_content =~ /(\W|^)#{Regexp.escape(helper_name)}(\W|$)/
164
163
  used_recipes.concat(used_recipes_by_helper.map { |recipe_def| @platform.decode_recipe(recipe_def) })
165
164
  used_recipes.uniq!
166
165
  end
@@ -214,6 +213,7 @@ module HybridPlatformsConductor
214
213
  INVALID_LIBRARY_METHODS = [
215
214
  'initialize'
216
215
  ]
216
+ private_constant :INVALID_LIBRARY_METHODS
217
217
 
218
218
  # Get the user defined library methods, per cookbook.
219
219
  # Keep a memory cache of it.
@@ -242,9 +242,9 @@ module HybridPlatformsConductor
242
242
  # * Parameters::
243
243
  # * *cookbook* (Symbol): Cookbook name
244
244
  # * *cookbook_dir* (String): Cookbook directory
245
- def for_each_cookbook(&block)
245
+ def for_each_cookbook(&)
246
246
  @platform.known_cookbook_paths.each do |cookbook_path|
247
- cookbooks_in(cookbook_path).each(&block)
247
+ cookbooks_in(cookbook_path).each(&)
248
248
  end
249
249
  end
250
250
 
@@ -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}")
@@ -16,7 +16,7 @@ module HybridPlatformsConductor
16
16
  def init
17
17
  # This method is called when initializing a new instance of this platform handler, for a given repository.
18
18
  inv_file = "#{@repository_path}/inventory.yaml"
19
- @inventory = File.exist?(inv_file) ? YAML.safe_load(File.read(inv_file)) : {}
19
+ @inventory = File.exist?(inv_file) ? YAML.safe_load_file(inv_file) : {}
20
20
  end
21
21
 
22
22
  # Get the list of known nodes.
@@ -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.
@@ -696,6 +696,7 @@ class ProxmoxWaiter
696
696
 
697
697
  # Timeout in seconds before giving up on a lock
698
698
  LOCK_TIMEOUT = 30
699
+ private_constant :LOCK_TIMEOUT
699
700
 
700
701
  # Get the IP address of a given LXC container
701
702
  #
@@ -85,8 +85,8 @@ begin
85
85
 
86
86
  proxmox_waiter = ProxmoxWaiter.new(
87
87
  config_file,
88
- ENV['hpc_user_for_proxmox'],
89
- ENV['hpc_password_for_proxmox'],
88
+ ENV.fetch('hpc_user_for_proxmox', nil),
89
+ ENV.fetch('hpc_password_for_proxmox', nil),
90
90
  ENV['hpc_realm_for_proxmox'] || 'pam'
91
91
  )
92
92
 
@@ -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)
@@ -518,6 +518,7 @@ module HybridPlatformsConductor
518
518
  # Consider that it is to be used on the following patterns: (config|create|destroy)_<ID>.json
519
519
  # So remaining length is 255 - 13 = 242 characters.
520
520
  MAX_FILE_ID_SIZE = 242
521
+ private_constant :MAX_FILE_ID_SIZE
521
522
 
522
523
  # Get an ID unique for this node/environment and that can be used in file names.
523
524
  #
@@ -529,7 +530,7 @@ module HybridPlatformsConductor
529
530
  if result.size > MAX_FILE_ID_SIZE
530
531
  # Truncate it, but add a unique ID in it.
531
532
  result = "-#{Digest::MD5.hexdigest(result)[0..7]}"
532
- 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
533
534
  end
534
535
  result
535
536
  end
@@ -51,6 +51,7 @@ module HybridPlatformsConductor
51
51
  private
52
52
 
53
53
  TEMPLATES_PATH = File.expand_path("#{File.dirname(__FILE__)}/templates")
54
+ private_constant :TEMPLATES_PATH
54
55
 
55
56
  # Render a given ERB template into a String
56
57
  #
@@ -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?
@@ -87,8 +87,8 @@ module HybridPlatformsConductor
87
87
 
88
88
  with_credentials_for(:keepass, resource: keepass_secrets_info[:database]) do |_user, password|
89
89
  Tempfile.create('hpc_keepass') do |xml_file|
90
- key_file = ENV['hpc_key_file_for_keepass']
91
- password_enc = ENV['hpc_password_enc_for_keepass']
90
+ key_file = ENV.fetch('hpc_key_file_for_keepass', nil)
91
+ password_enc = ENV.fetch('hpc_password_enc_for_keepass', nil)
92
92
  keepass_credentials = {}
93
93
  keepass_credentials[:password] = password.to_unprotected if password
94
94
  keepass_credentials[:password_enc] = password_enc if password_enc
@@ -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
@@ -116,6 +116,7 @@ module HybridPlatformsConductor
116
116
  url: 'URL',
117
117
  user_name: 'UserName'
118
118
  }
119
+ private_constant :FIELDS
119
120
 
120
121
  # Parse XML secrets from a Nokogiri XML group node
121
122
  #
@@ -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'
@@ -26,12 +26,12 @@ module HybridPlatformsConductor
26
26
  cmd_runner: @cmd_runner
27
27
  ).known_platforms.first
28
28
  unless example_platform.nil?
29
- tests.concat [
29
+ tests.push(
30
30
  "#{CmdRunner.executables_prefix}get_impacted_nodes --platform #{example_platform.name} --show-commands"
31
- ]
31
+ )
32
32
  example_node = example_platform.known_nodes.first
33
33
  unless example_node.nil?
34
- tests.concat [
34
+ tests.push(
35
35
  "#{CmdRunner.executables_prefix}check-node --node #{example_node} --show-commands",
36
36
  "#{CmdRunner.executables_prefix}deploy --node #{example_node} --show-commands --why-run",
37
37
  "#{CmdRunner.executables_prefix}last_deploys --node #{example_node} --show-commands",
@@ -39,7 +39,7 @@ module HybridPlatformsConductor
39
39
  "#{CmdRunner.executables_prefix}report --node #{example_node} --format stdout",
40
40
  "#{CmdRunner.executables_prefix}run --node #{example_node} --show-commands --interactive",
41
41
  "#{CmdRunner.executables_prefix}topograph --from \"--node #{example_node}\" --to \"--node #{example_node}\" --skip-run --output graphviz:graph.gv"
42
- ]
42
+ )
43
43
  end
44
44
  end
45
45
  tests.sort.each do |cmd|
@@ -48,7 +48,7 @@ module HybridPlatformsConductor
48
48
  assert_equal(exit_status, 0, "Command #{cmd} returned code #{exit_status}:\n#{stdout}")
49
49
  end
50
50
  # Remove the file created by Topograph if it exists
51
- File.unlink('graph.gv') if File.exist?('graph.gv')
51
+ FileUtils.rm_f('graph.gv')
52
52
  end
53
53
 
54
54
  end
@@ -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
@@ -20,11 +20,11 @@ module HybridPlatformsConductor
20
20
  _exit_status, stdout, _stderr = @cmd_runner.run_cmd(<<~EO_BASH, log_to_stdout: log_debug?, no_exception: true, expected_code: [0, 1])
21
21
  cd #{@platform.repository_path} && \
22
22
  git --no-pager log \
23
- --pretty=format:\"%H\" \
23
+ --pretty=format:"%H" \
24
24
  --graph \
25
25
  $(git merge-base \
26
26
  --octopus \
27
- $(git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:\"%P\") \
27
+ $(git --no-pager log #{merge_commit_id} --max-count 1 --pretty=format:"%P") \
28
28
  )..#{merge_commit_id}
29
29
  | grep '|'
30
30
  EO_BASH
@@ -13,7 +13,7 @@ module HybridPlatformsConductor
13
13
  @nodes_handler.prefetch_metadata_of @nodes_handler.known_nodes, :veid
14
14
  veids = @nodes_handler.
15
15
  known_nodes.
16
- to_h { |node| [node, @nodes_handler.get_veid_of(node) ? @nodes_handler.get_veid_of(node).to_i : nil] }
16
+ to_h { |node| [node, @nodes_handler.get_veid_of(node)&.to_i] }
17
17
 
18
18
  # Check there are no duplicates
19
19
  veids.group_by { |_node, veid| veid }.each do |veid, nodes|
@@ -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|
@@ -56,6 +56,7 @@ module HybridPlatformsConductor
56
56
  private
57
57
 
58
58
  TEMPLATES_PATH = File.expand_path("#{__dir__}/templates")
59
+ private_constant :TEMPLATES_PATH
59
60
 
60
61
  # Render a given ERB template into a String
61
62
  #
@@ -55,7 +55,7 @@ module HybridPlatformsConductor
55
55
  def dump_json_for(nodes_selectors)
56
56
  nodes = @nodes_handler.select_nodes(nodes_selectors)
57
57
  unless @skip_run
58
- nodes.map { |node| @nodes_handler.platform_for(node) }.uniq.each.each do |platform_handler|
58
+ nodes.map { |node| @nodes_handler.platform_for(node) }.uniq.each do |platform_handler|
59
59
  platform_handler.prepare_why_run_deploy_for_json_dump if platform_handler.respond_to?(:prepare_why_run_deploy_for_json_dump)
60
60
  end
61
61
  @deployer.concurrent_execution = true
@@ -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