|
1 |
| -require 'serverspec' |
2 |
| -require 'puppet_litmus' |
3 |
| -include PuppetLitmus # rubocop:disable Style/MixinUsage This is fine |
4 |
| - |
5 |
| -if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost' |
6 |
| - puts 'Running tests against this machine !' |
7 |
| - if Gem.win_platform? |
8 |
| - set :backend, :cmd |
9 |
| - else |
10 |
| - set :backend, :exec |
11 |
| - end |
12 |
| -else |
13 |
| - # load inventory |
14 |
| - inventory_hash = inventory_hash_from_inventory_file |
15 |
| - node_config = config_from_node(inventory_hash, ENV['TARGET_HOST']) |
16 |
| - |
17 |
| - if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes') |
18 |
| - host = ENV['TARGET_HOST'] |
19 |
| - set :backend, :docker |
20 |
| - set :docker_container, host |
21 |
| - elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes') |
22 |
| - set :backend, :ssh |
23 |
| - options = Net::SSH::Config.for(host) |
24 |
| - options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil? |
25 |
| - options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil? |
26 |
| - options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil? |
27 |
| - options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil? |
28 |
| - options[:verify_host_key] = Net::SSH::Verifiers::Never.new unless node_config.dig('ssh', 'host-key-check').nil? |
29 |
| - host = if ENV['TARGET_HOST'].include?(':') |
30 |
| - ENV['TARGET_HOST'].split(':').first |
31 |
| - else |
32 |
| - ENV['TARGET_HOST'] |
33 |
| - end |
34 |
| - set :host, options[:host_name] || host |
35 |
| - set :ssh_options, options |
36 |
| - set :request_pty, true |
37 |
| - elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes') |
38 |
| - require 'winrm' |
39 |
| - |
40 |
| - set :backend, :winrm |
41 |
| - set :os, family: 'windows' |
42 |
| - user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil? |
43 |
| - pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil? |
44 |
| - endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" |
45 |
| - |
46 |
| - opts = { |
47 |
| - user: user, |
48 |
| - password: pass, |
49 |
| - endpoint: endpoint, |
50 |
| - operation_timeout: 300, |
51 |
| - } |
52 |
| - |
53 |
| - winrm = WinRM::Connection.new opts |
54 |
| - Specinfra.configuration.winrm = winrm |
55 |
| - end |
56 |
| -end |
| 1 | +# frozen_string_literal: true |
57 | 2 |
|
| 3 | +require 'puppet_litmus' |
58 | 4 | require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))
|
| 5 | + |
| 6 | +PuppetLitmus.configure! |
0 commit comments