hybrid_platforms_conductor 32.3.6 → 32.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nodes_to_deploy +11 -5
  3. data/lib/hybrid_platforms_conductor/deployer.rb +33 -12
  4. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +82 -28
  5. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/platform_handler_plugin.rb.sample +1 -1
  6. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +1 -1
  7. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +1 -1
  8. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +1 -1
  9. data/lib/hybrid_platforms_conductor/hpc_plugins/test/hostname.rb +1 -1
  10. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  11. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +1 -1
  12. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +1 -1
  13. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +1 -1
  14. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +6 -7
  15. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +7 -6
  16. data/lib/hybrid_platforms_conductor/nodes_handler.rb +45 -1
  17. data/lib/hybrid_platforms_conductor/services_handler.rb +9 -13
  18. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  19. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +35 -0
  20. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +41 -2
  21. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +68 -12
  22. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +1 -1
  23. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +23 -9
  24. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +15 -0
  25. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +28 -0
  26. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +71 -0
  27. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +10 -0
  28. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +25 -0
  29. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +17 -7
  30. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +14 -14
  31. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +137 -33
  32. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +1 -1
  33. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +2 -2
  34. metadata +13 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e16a6630a51ed9208fa4a3cecfce6604c65a39cb782d9efa426898ec980d5071
4
- data.tar.gz: 33f38588a1b795e323f76e909ef301905cacf9d77c0a418ac0809713960659b6
3
+ metadata.gz: d6b6259b1f05bb082b4f2c6820f74b6c90dad15f5868a311337429b80d233500
4
+ data.tar.gz: c5f58e3ba104ba2365addea64ab08c43a4fe9797430c950bf01258eb7bfcdc1b
5
5
  SHA512:
6
- metadata.gz: 16a3b130741673e1ce4bfee15a5a4d8c45c66e5712e130a746f2d6be1e9940a1052a2c9195cce748831ca1652cc52255002226b31c0494516250b5359074c592
7
- data.tar.gz: 920f8a21967bc69ecaf6072eec422e119e989415ddcd26d9e42e2d38779a35ddcfe58f5819cd3165c12799cf297dc5530da9a8d80ea6ae8c6a81c662d62c8fda
6
+ metadata.gz: b079e89a17630ed994614bc24e76ba2154ae52fcaf3712feaaef9e823487d933d6b33b87b3aa253e8d11270d5765d061349c4a37f467e81d729d994ed1f7b72e
7
+ data.tar.gz: 4a89e197bed2c87dbc10d66d8a3f6240c68deb7c2799962be282634c3c109b653c2a66725baa5ca44e38fd0bf1ec992148720047668c1c7786bd494a8e3836e7
data/bin/nodes_to_deploy CHANGED
@@ -72,11 +72,17 @@ unless ignore_deploy_info
72
72
  commit_id = node_deploy_info["commit_id_#{repo_idx}".to_sym]
73
73
  impacted_nodes = cache_impacted_nodes.dig(repo_name, commit_id)
74
74
  if impacted_nodes.nil?
75
- impacted_nodes, _single_impacted_nodes, _impacted_services, _impact_global = nodes_handler.impacted_nodes_from_git_diff(
76
- repo_name,
77
- from_commit: commit_id,
78
- to_commit: 'master'
79
- )
75
+ begin
76
+ impacted_nodes, _single_impacted_nodes, _impacted_services, _impact_global = nodes_handler.impacted_nodes_from_git_diff(
77
+ repo_name,
78
+ from_commit: commit_id,
79
+ to_commit: 'master'
80
+ )
81
+ rescue HybridPlatformsConductor::NodesHandler::GitError
82
+ # Consider the node was deployed with a non-release branch commit (as it is missing)
83
+ # So we have to make sure we deploy it again
84
+ impacted_nodes = [node]
85
+ end
80
86
  cache_impacted_nodes[repo_name] = {} unless cache_impacted_nodes.key?(repo_name)
81
87
  cache_impacted_nodes[repo_name][commit_id] = impacted_nodes
82
88
  end
@@ -18,8 +18,31 @@ module HybridPlatformsConductor
18
18
  # Gives ways to deploy on several nodes
19
19
  class Deployer
20
20
 
21
+ # Extend the Config DSL
22
+ module ConfigDSLExtension
23
+
24
+ # Integer: Timeout (in seconds) for packaging repositories
25
+ attr_reader :packaging_timeout_secs
26
+
27
+ # Mixin initializer
28
+ def init_deployer_config
29
+ @packaging_timeout_secs = 60
30
+ end
31
+
32
+ # Set the packaging timeout
33
+ #
34
+ # Parameters::
35
+ # * *packaging_timeout_secs* (Integer): The packaging timeout, in seconds
36
+ def packaging_timeout(packaging_timeout_secs)
37
+ @packaging_timeout_secs = packaging_timeout_secs
38
+ end
39
+
40
+ end
41
+
21
42
  include LoggerHelpers
22
43
 
44
+ Config.extend_config_dsl_with ConfigDSLExtension, :init_nodes_handler_config
45
+
23
46
  # Do we use why-run mode while deploying? [default = false]
24
47
  # Boolean
25
48
  attr_accessor :use_why_run
@@ -135,9 +158,6 @@ module HybridPlatformsConductor
135
158
  # String: File used as a Futex for packaging
136
159
  PACKAGING_FUTEX_FILE = "#{Dir.tmpdir}/hpc_packaging"
137
160
 
138
- # Integer: Timeout in seconds to get the packaging Futex
139
- PACKAGING_FUTEX_TIMEOUT = 60
140
-
141
161
  # Deploy on a given list of nodes selectors.
142
162
  # The workflow is the following:
143
163
  # 1. Package the services to be deployed, considering the nodes, services and context (options, secrets, environment...)
@@ -176,7 +196,7 @@ module HybridPlatformsConductor
176
196
 
177
197
  # Package the deployment
178
198
  # Protect packaging by a Futex
179
- Futex.new(PACKAGING_FUTEX_FILE, timeout: PACKAGING_FUTEX_TIMEOUT).open do
199
+ Futex.new(PACKAGING_FUTEX_FILE, timeout: @config.packaging_timeout_secs).open do
180
200
  section 'Packaging deployment' do
181
201
  @services_handler.package(
182
202
  services: services_to_deploy,
@@ -460,6 +480,7 @@ module HybridPlatformsConductor
460
480
  outputs = @actions_executor.execute_actions(
461
481
  Hash[services.map do |node, node_services|
462
482
  image_id = @nodes_handler.get_image_of(node)
483
+ sudo = (ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(node)} ")
463
484
  # Install My_company corporate certificates if present
464
485
  certificate_actions =
465
486
  if @local_environment && ENV['hpc_certificates']
@@ -469,20 +490,20 @@ module HybridPlatformsConductor
469
490
  when 'debian_9', 'debian_10'
470
491
  [
471
492
  {
472
- remote_bash: "#{ssh_user == 'root' ? '' : 'sudo '}apt update && #{ssh_user == 'root' ? '' : 'sudo '}apt install -y ca-certificates"
493
+ remote_bash: "#{sudo}apt update && #{sudo}apt install -y ca-certificates"
473
494
  },
474
495
  {
475
496
  scp: {
476
497
  ENV['hpc_certificates'] => '/usr/local/share/ca-certificates',
477
498
  :sudo => ssh_user != 'root'
478
499
  },
479
- remote_bash: "#{ssh_user == 'root' ? '' : 'sudo '}update-ca-certificates"
500
+ remote_bash: "#{sudo}update-ca-certificates"
480
501
  }
481
502
  ]
482
503
  when 'centos_7'
483
504
  [
484
505
  {
485
- remote_bash: "#{ssh_user == 'root' ? '' : 'sudo '}yum install -y ca-certificates"
506
+ remote_bash: "#{sudo}yum install -y ca-certificates"
486
507
  },
487
508
  {
488
509
  scp: Hash[Dir.glob("#{ENV['hpc_certificates']}/*.crt").map do |cert_file|
@@ -492,8 +513,8 @@ module HybridPlatformsConductor
492
513
  ]
493
514
  end].merge(sudo: ssh_user != 'root'),
494
515
  remote_bash: [
495
- "#{ssh_user == 'root' ? '' : 'sudo '}update-ca-trust enable",
496
- "#{ssh_user == 'root' ? '' : 'sudo '}update-ca-trust extract"
516
+ "#{sudo}update-ca-trust enable",
517
+ "#{sudo}update-ca-trust extract"
497
518
  ]
498
519
  }
499
520
  ]
@@ -512,7 +533,7 @@ module HybridPlatformsConductor
512
533
  # Install the mutex lock and acquire it
513
534
  {
514
535
  scp: { "#{__dir__}/mutex_dir" => '.' },
515
- remote_bash: "while ! #{ssh_user == 'root' ? '' : 'sudo '}./mutex_dir lock /tmp/hybrid_platforms_conductor_deploy_lock \"$(ps -o ppid= -p $$)\"; do echo -e 'Another deployment is running on #{node}. Waiting for it to finish to continue...' ; sleep 5 ; done"
536
+ remote_bash: "while ! #{sudo}./mutex_dir lock /tmp/hybrid_platforms_conductor_deploy_lock \"$(ps -o ppid= -p $$)\"; do echo -e 'Another deployment is running on #{node}. Waiting for it to finish to continue...' ; sleep 5 ; done"
516
537
  }
517
538
  ] +
518
539
  certificate_actions +
@@ -528,7 +549,7 @@ module HybridPlatformsConductor
528
549
  Hash[services.keys.map do |node|
529
550
  [
530
551
  node,
531
- { remote_bash: "#{ssh_user == 'root' ? '' : 'sudo '}./mutex_dir unlock /tmp/hybrid_platforms_conductor_deploy_lock" }
552
+ { remote_bash: "#{ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(node)} "}./mutex_dir unlock /tmp/hybrid_platforms_conductor_deploy_lock" }
532
553
  ]
533
554
  end],
534
555
  timeout: 10,
@@ -575,7 +596,7 @@ module HybridPlatformsConductor
575
596
  [
576
597
  node,
577
598
  {
578
- remote_bash: "#{ssh_user == 'root' ? '' : 'sudo '}mkdir -p /var/log/deployments",
599
+ remote_bash: "#{ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(node)} "}mkdir -p /var/log/deployments",
579
600
  scp: {
580
601
  log_file => '/var/log/deployments',
581
602
  :sudo => ssh_user != 'root',
@@ -10,13 +10,46 @@ module HybridPlatformsConductor
10
10
  # Connect to node using SSH
11
11
  class Ssh < HybridPlatformsConductor::Connector
12
12
 
13
+ # Exception raise when a node is not connectable using SSH
14
+ class NotConnectableError < RuntimeError
15
+ end
16
+
13
17
  module PlatformsDslSsh
14
18
 
19
+ # List of SSH connection transformations:
20
+ # * *nodes_selectors_stack* (Array<Object>): Stack of nodes selectors impacted by this rule
21
+ # * *transform* (Proc): Code called to transform SSH connection info:
22
+ # Parameters::
23
+ # * *node* (String): Node for which we transform the SSH connection
24
+ # * *connection* (String or nil): The connection host or IP, or nil if none
25
+ # * *connection_user* (String): The connection user
26
+ # * *gateway* (String or nil): The gateway name, or nil if none
27
+ # * *gateway_user* (String or nil): The gateway user, or nil if none
28
+ # Result::
29
+ # * String: The transformed connection host or IP, or nil if none
30
+ # * String: The transformed connection user
31
+ # * String or nil: The transformed gateway name, or nil if none
32
+ # * String or nil: The transformed gateway user, or nil if none
33
+ # Array< Hash<Symbol, Object> >
34
+ attr_reader :ssh_connection_transforms
35
+
15
36
  # Initialize the DSL
16
37
  def init_ssh
17
38
  # List of gateway configurations, per gateway config name
18
39
  # Hash<Symbol, String>
19
40
  @gateways = {}
41
+ @ssh_connection_transforms = []
42
+ end
43
+
44
+ # Define a transformation of SSH connection.
45
+ #
46
+ # Parameters::
47
+ # * *transform* (Proc): Code to be called to transform an SSH connection (see ssh_connection_transforms signature for details)
48
+ def transform_ssh_connection(&transform)
49
+ @ssh_connection_transforms << {
50
+ nodes_selectors_stack: current_nodes_selectors_stack,
51
+ transform: transform
52
+ }
20
53
  end
21
54
 
22
55
  # Register a new gateway configuration
@@ -268,7 +301,7 @@ module HybridPlatformsConductor
268
301
  #{File.basename(from)} | \
269
302
  #{ssh_exec} \
270
303
  #{ssh_url} \
271
- \"#{sudo ? 'sudo ' : ''}tar \
304
+ \"#{sudo ? "#{@nodes_handler.sudo_on(@node)} " : ''}tar \
272
305
  --extract \
273
306
  --gunzip \
274
307
  --file - \
@@ -291,7 +324,7 @@ module HybridPlatformsConductor
291
324
  # Result::
292
325
  # * String: The ssh URL connecting to the current node
293
326
  def ssh_url
294
- "#{@ssh_user}@hpc.#{@node}"
327
+ "hpc.#{@node}"
295
328
  end
296
329
 
297
330
  # Get an SSH configuration content giving access to nodes of the platforms with the current configuration
@@ -314,14 +347,6 @@ module HybridPlatformsConductor
314
347
  # ENDPOINTS #
315
348
  #############
316
349
 
317
- Host *
318
- User #{@ssh_user}
319
- # Default control socket path to be used when multiplexing SSH connections
320
- ControlPath #{control_master_file('%h', '%p', '%r')}
321
- #{open_ssh_major_version >= 7 ? 'PubkeyAcceptedKeyTypes +ssh-dss' : ''}
322
- #{known_hosts_file.nil? ? '' : "UserKnownHostsFile #{known_hosts_file}"}
323
- #{@ssh_strict_host_key_checking ? '' : 'StrictHostKeyChecking no'}
324
-
325
350
  EOS
326
351
 
327
352
  # Add each node
@@ -329,17 +354,37 @@ module HybridPlatformsConductor
329
354
  @nodes_handler.prefetch_metadata_of nodes, %i[private_ips hostname host_ip description]
330
355
  nodes.sort.each do |node|
331
356
  # Generate the conf for the node
332
- connection, gateway, gateway_user = connection_info_for(node)
333
- config_content << "# #{node} - #{connection} - #{@nodes_handler.get_description_of(node) || ''}\n"
334
- config_content << "Host #{ssh_aliases_for(node).join(' ')}\n"
335
- config_content << " Hostname #{connection}\n"
336
- config_content << " ProxyCommand #{ssh_exec} -q -W %h:%p #{gateway_user}@#{gateway}\n" unless gateway.nil?
337
- if @passwords.key?(node)
338
- config_content << " PreferredAuthentications password\n"
339
- config_content << " PubkeyAuthentication no\n"
357
+ connection, connection_user, gateway, gateway_user = connection_info_for(node, no_exception: true)
358
+ if connection.nil?
359
+ config_content << "# #{node} - Not connectable using SSH - #{@nodes_handler.get_description_of(node) || ''}\n"
360
+ else
361
+ config_content << "# #{node} - #{connection} - #{@nodes_handler.get_description_of(node) || ''}\n"
362
+ config_content << "Host #{ssh_aliases_for(node).join(' ')}\n"
363
+ config_content << " Hostname #{connection}\n"
364
+ config_content << " User \"#{connection_user}\"\n" if connection_user != @ssh_user
365
+ config_content << " ProxyCommand #{ssh_exec} -q -W %h:%p #{gateway_user}@#{gateway}\n" unless gateway.nil?
366
+ if @passwords.key?(node)
367
+ config_content << " PreferredAuthentications password\n"
368
+ config_content << " PubkeyAuthentication no\n"
369
+ end
340
370
  end
341
371
  config_content << "\n"
342
372
  end
373
+ # Add global definitions at the end of the SSH config, as they might be overriden by previous ones, and first match wins.
374
+ config_content << <<~EOS
375
+ ###########
376
+ # GLOBALS #
377
+ ###########
378
+
379
+ Host *
380
+ User #{@ssh_user}
381
+ # Default control socket path to be used when multiplexing SSH connections
382
+ ControlPath #{control_master_file('%h', '%p', '%r')}
383
+ #{open_ssh_major_version >= 7 ? 'PubkeyAcceptedKeyTypes +ssh-dss' : ''}
384
+ #{known_hosts_file.nil? ? '' : "UserKnownHostsFile #{known_hosts_file}"}
385
+ #{@ssh_strict_host_key_checking ? '' : 'StrictHostKeyChecking no'}
386
+
387
+ EOS
343
388
  config_content
344
389
  end
345
390
 
@@ -442,7 +487,7 @@ module HybridPlatformsConductor
442
487
  with_lock_on_control_master_for(node) do |current_users, user_id|
443
488
  working_master = false
444
489
  ssh_exec = ssh_exec_for(node)
445
- ssh_url = "#{@ssh_user}@hpc.#{node}"
490
+ ssh_url = "hpc.#{node}"
446
491
  if current_users.empty?
447
492
  log_debug "[ ControlMaster - #{ssh_url} ] - Creating SSH ControlMaster..."
448
493
  # Create the control master
@@ -510,7 +555,7 @@ module HybridPlatformsConductor
510
555
  user_locks_mutex.synchronize do
511
556
  user_locks.each do |node, user_id|
512
557
  with_lock_on_control_master_for(node, user_id: user_id) do |current_users, user_id|
513
- ssh_url = "#{@ssh_user}@hpc.#{node}"
558
+ ssh_url = "hpc.#{node}"
514
559
  log_warn "[ ControlMaster - #{ssh_url} ] - Current process/thread was not part of the ControlMaster users anymore whereas it should have been" unless current_users.include?(user_id)
515
560
  remaining_users = current_users - [user_id]
516
561
  if remaining_users.empty?
@@ -554,8 +599,9 @@ module HybridPlatformsConductor
554
599
  # TODO: Add test case when control file is missing ad when it is stale
555
600
  # Get the list of existing process/thread ids using this control master
556
601
  existing_users = File.exist?(control_master_users_file) ? File.read(control_master_users_file).split("\n") : []
557
- ssh_url = "#{@ssh_user}@hpc.#{node}"
558
- control_path_file = control_master_file(connection_info_for(node).first, '22', @ssh_user)
602
+ ssh_url = "hpc.#{node}"
603
+ connection, connection_user, _gateway, _gateway_user = connection_info_for(node)
604
+ control_path_file = control_master_file(connection, '22', connection_user)
559
605
  if existing_users.empty?
560
606
  # Make sure there is no stale one.
561
607
  if File.exist?(control_path_file)
@@ -587,7 +633,7 @@ module HybridPlatformsConductor
587
633
  # * *port* (String): The port. Can be a string as ssh config uses wildchars.
588
634
  # * *user* (String): The user
589
635
  def control_master_file(host, port, user)
590
- "#{@tmp_dir}/hpc_actions_executor_mux_#{host}_#{port}_#{user}"
636
+ "#{@tmp_dir}/hpc_ssh_mux_#{host}_#{port}_#{user}"
591
637
  end
592
638
 
593
639
  # Provide a bootstrapped ssh executable that includes an SSH config allowing access to nodes.
@@ -619,7 +665,7 @@ module HybridPlatformsConductor
619
665
  nodes.sort.each do |node|
620
666
  host_keys = @nodes_handler.get_host_keys_of(node)
621
667
  if host_keys && !host_keys.empty?
622
- connection, _gateway, _gateway_user = connection_info_for(node)
668
+ connection, _connection_user, _gateway, _gateway_user = connection_info_for(node)
623
669
  host_keys.each do |host_key|
624
670
  file.puts "#{connection} #{host_key}"
625
671
  end
@@ -652,11 +698,13 @@ module HybridPlatformsConductor
652
698
  #
653
699
  # Parameters::
654
700
  # * *node* (String): The node to access
701
+ # * *no_exception* (Boolean): Should we skip exceptions in case of no connection possible? [default: false]
655
702
  # Result::
656
- # * String: The real hostname or IP to be used to connect
703
+ # * String: The real hostname or IP to be used to connect, or nil if none and no_exception is true
704
+ # * String: The real user to be used to connect, or nil if none and no_exception is true
657
705
  # * String or nil: The gateway name to be used (should be defined by the gateways configurations), or nil if no gateway to be used.
658
706
  # * String or nil: The gateway user to be used, or nil if none.
659
- def connection_info_for(node)
707
+ def connection_info_for(node, no_exception: false)
660
708
  connection =
661
709
  if @nodes_handler.get_host_ip_of(node)
662
710
  @nodes_handler.get_host_ip_of(node)
@@ -665,12 +713,18 @@ module HybridPlatformsConductor
665
713
  elsif @nodes_handler.get_hostname_of(node)
666
714
  @nodes_handler.get_hostname_of(node)
667
715
  else
668
- raise "No connection possible to #{node}"
716
+ nil
669
717
  end
718
+ connection_user = @ssh_user
670
719
  gateway = @nodes_handler.get_gateway_of node
671
720
  gateway_user = @nodes_handler.get_gateway_user_of node
672
721
  gateway_user = @ssh_gateway_user if !gateway.nil? && gateway_user.nil?
673
- [connection, gateway, gateway_user]
722
+ # In case we want to transform the connection info, do it here.
723
+ @nodes_handler.select_confs_for_node(node, @config.ssh_connection_transforms).each do |transform_info|
724
+ connection, connection_user, gateway, gateway_user = transform_info[:transform].call(node, connection, connection_user, gateway, gateway_user)
725
+ end
726
+ raise NotConnectableError, "No connection possible to #{node}" if connection.nil? && !no_exception
727
+ [connection, connection_user, gateway, gateway_user]
674
728
  end
675
729
 
676
730
  # Get the possible SSH aliases for a given node.
@@ -173,7 +173,7 @@ module HybridPlatformsConductor
173
173
  # * *local_environment* (Boolean): Are we deploying to a local environment?
174
174
  def package(services:, secrets:, local_environment:)
175
175
  # This method should take all actions to prepare the repository to be deployed on nodes later.
176
- File.write('temporary_secrets_to_be_deployed.json', secrets)
176
+ File.write("#{@repository_path}/temporary_secrets_to_be_deployed.json", secrets.to_json)
177
177
  # Usually it is meant to package the deployment scripts.
178
178
  @cmd_runner.run_cmd "cd #{@repository_path} && ./scripts/package_in_debian_format.sh"
179
179
  end
@@ -404,7 +404,7 @@ module HybridPlatformsConductor
404
404
  {
405
405
  proxmox_test_info[:sync_node] => {
406
406
  remote_bash: {
407
- commands: "#{@actions_executor.connector(:ssh).ssh_user == 'root' ? '' : 'sudo -E '}./proxmox/#{cmd}",
407
+ commands: "#{@actions_executor.connector(:ssh).ssh_user == 'root' ? '' : "#{@nodes_handler.sudo_on(proxmox_test_info[:sync_node])} -E "}./proxmox/#{cmd}",
408
408
  env: {
409
409
  'hpc_user_for_proxmox' => user,
410
410
  'hpc_password_for_proxmox' => password,
@@ -15,7 +15,7 @@ module HybridPlatformsConductor
15
15
  def test_on_node
16
16
  now = Time.now
17
17
  {
18
- 'sudo ls -t /var/log/deployments' => proc do |stdout|
18
+ "#{@nodes_handler.sudo_on(@node)} ls -t /var/log/deployments" => proc do |stdout|
19
19
  if stdout.empty?
20
20
  error 'Node has never been deployed using deploy (/var/log/deployments is empty)'
21
21
  elsif stdout.first =~ /No such file or directory/
@@ -17,7 +17,7 @@ module HybridPlatformsConductor
17
17
  Hash[
18
18
  @config.aggregate_files_rules(@nodes_handler, @node).map do |path, rule_info|
19
19
  [
20
- "if sudo /bin/bash -c '[[ -d \"#{path}\" ]]' ; then echo 1 ; else echo 0 ; fi",
20
+ "if #{@nodes_handler.sudo_on(@node)} /bin/bash -c '[[ -d \"#{path}\" ]]' ; then echo 1 ; else echo 0 ; fi",
21
21
  {
22
22
  validator: proc do |stdout, stderr|
23
23
  case stdout.last
@@ -10,7 +10,7 @@ module HybridPlatformsConductor
10
10
  # Check my_test_plugin.rb.sample documentation for signature details.
11
11
  def test_on_node
12
12
  {
13
- 'sudo hostname -s' => proc do |stdout|
13
+ "#{@nodes_handler.sudo_on(@node)} hostname -s" => proc do |stdout|
14
14
  assert_equal stdout.first, @node, "Expected hostname to be #{@node}, but got #{stdout.first} instead."
15
15
  end
16
16
  }
@@ -10,7 +10,7 @@ module HybridPlatformsConductor
10
10
  # Check my_test_plugin.rb.sample documentation for signature details.
11
11
  def test_on_node
12
12
  {
13
- 'sudo hostname -I' => proc do |stdout|
13
+ "#{@nodes_handler.sudo_on(@node)} hostname -I" => proc do |stdout|
14
14
  if stdout.first.nil?
15
15
  error 'No IP returned by "hostname -I"'
16
16
  else
@@ -57,7 +57,7 @@ module HybridPlatformsConductor
57
57
  # Check my_test_plugin.rb.sample documentation for signature details.
58
58
  def test_on_node
59
59
  {
60
- "sudo cat /etc/passwd" => proc do |stdout|
60
+ "#{@nodes_handler.sudo_on(@node)} cat /etc/passwd" => proc do |stdout|
61
61
  passwd_users = stdout.map { |passwd_line| passwd_line.split(':').first }
62
62
  missing_users = @nodes_handler.
63
63
  select_confs_for_node(@node, @config.users_that_should_be_present).
@@ -61,7 +61,7 @@ module HybridPlatformsConductor
61
61
  # Check my_test_plugin.rb.sample documentation for signature details.
62
62
  def test_on_node
63
63
  {
64
- 'sudo mount' => proc do |stdout|
64
+ "#{@nodes_handler.sudo_on(@node)} mount" => proc do |stdout|
65
65
  mounts_info = stdout.map do |line|
66
66
  fields = line.split
67
67
  {
@@ -50,7 +50,7 @@ module HybridPlatformsConductor
50
50
  # Check my_test_plugin.rb.sample documentation for signature details.
51
51
  def test_on_node
52
52
  {
53
- "sudo /usr/bin/find / \\( #{@nodes_handler.
53
+ "#{@nodes_handler.sudo_on(@node)} /usr/bin/find / \\( #{@nodes_handler.
54
54
  select_confs_for_node(@node, @config.ignored_orphan_files_paths).
55
55
  inject(DIRECTORIES_TO_ALWAYS_IGNORE) { |merged_paths, paths_to_ignore_info| merged_paths + paths_to_ignore_info[:ignored_paths] }.
56
56
  uniq.