1 # frozen_string_literal: true
4 require 'puppet_litmus'
5 require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))
8 if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost'
9 puts 'Running tests against this machine !'
17 inventory_hash = inventory_hash_from_inventory_file
18 node_config = config_from_node(inventory_hash, ENV['TARGET_HOST'])
20 if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes')
21 host = ENV['TARGET_HOST']
23 set :docker_container, host
24 elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes')
26 options = Net::SSH::Config.for(host)
27 options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil?
28 options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil?
29 options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil?
30 options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
31 options[:verify_host_key] = Net::SSH::Verifiers::Null.new unless node_config.dig('ssh', 'host-key-check').nil?
32 host = if ENV['TARGET_HOST'].include?(':')
33 ENV['TARGET_HOST'].split(':').first
37 set :host, options[:host_name] || host
38 set :ssh_options, options
39 elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes')
43 set :os, family: 'windows'
44 user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil?
45 pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil?
46 endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
52 operation_timeout: 300,
55 winrm = WinRM::Connection.new opts
56 Specinfra.configuration.winrm = winrm