diff -Nru serverspec-runner-1.2.2/bin/serverspec-runner serverspec-runner-1.3.8/bin/serverspec-runner --- serverspec-runner-1.2.2/bin/serverspec-runner 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/bin/serverspec-runner 2018-12-23 23:08:20.000000000 +0000 @@ -5,27 +5,36 @@ require 'rubygems' require 'rake' require 'getoptlong' +require 'serverspec-runner/version' raketask = 'spec' showtasks = false opts = GetoptLong.new( - ["--scenario", "-s", GetoptLong::REQUIRED_ARGUMENT], - ["--specroot", "-r", GetoptLong::REQUIRED_ARGUMENT], - ["--ssh_options", "-o", GetoptLong::REQUIRED_ARGUMENT], - ["--explain", "-e", GetoptLong::REQUIRED_ARGUMENT], - ["--tableformat", "-t", GetoptLong::REQUIRED_ARGUMENT], - ["--parallel", "-p", GetoptLong::REQUIRED_ARGUMENT], - ["--help", "-h", GetoptLong::NO_ARGUMENT], - ["--raketask", "-1", GetoptLong::REQUIRED_ARGUMENT], - ["--tmpdir", "-2", GetoptLong::REQUIRED_ARGUMENT], - ["--tasks", "-T", GetoptLong::NO_ARGUMENT] + ["--scenario", "-s", GetoptLong::REQUIRED_ARGUMENT], + ["--inventory", "-i", GetoptLong::REQUIRED_ARGUMENT], + ["--specroot", "-r", GetoptLong::REQUIRED_ARGUMENT], + ["--ssh_options", "-o", GetoptLong::REQUIRED_ARGUMENT], + ["--explain", "-e", GetoptLong::REQUIRED_ARGUMENT], + ["--tableformat", "-t", GetoptLong::REQUIRED_ARGUMENT], + ["--parallel", "-p", GetoptLong::REQUIRED_ARGUMENT], + ["--pattern", "-P", GetoptLong::REQUIRED_ARGUMENT], + ["--exclude-pattern", "-E", GetoptLong::REQUIRED_ARGUMENT], + ["--ignore-error-exit", "-I", GetoptLong::NO_ARGUMENT], + ["--activate-specroot", "-a", GetoptLong::NO_ARGUMENT], + ["--version", "-v", GetoptLong::NO_ARGUMENT], + ["--help", "-h", GetoptLong::NO_ARGUMENT], + ["--raketask", "-1", GetoptLong::REQUIRED_ARGUMENT], + ["--tmpdir", "-2", GetoptLong::REQUIRED_ARGUMENT], + ["--tasks", "-T", GetoptLong::NO_ARGUMENT] ) opts.each do |opt, arg| case opt when '--scenario' ENV['scenario'] = arg + when '--inventory' + ENV['inventory'] = arg when '--specroot' ENV['specroot'] = arg when '--ssh_options' @@ -36,23 +45,39 @@ ENV['tableformat'] = arg when '--parallel' ENV['parallels'] = arg + when '--pattern' + ENV['pattern'] = arg + when '--exclude-pattern' + ENV['exclude_pattern'] = arg + when '--ignore-error-exit' + ENV['ignore_error_exit'] = 'true' + when '--activate-specroot' + ENV['activate_specroot'] = 'true' when '--tmpdir' ENV['tmpdir'] = arg when '--raketask' raketask = arg when '--tasks' showtasks = true + when '--version' + puts ServerspecRunner::VERSION + exit 0 else puts "Usage: serverspec-runner (options)" - puts "-s, --scenario SCENARIO_FILE path to scenario yml file" - puts "-r, --specroot SPEC_ROOT path to spec tests root dir" - puts "-o, --ssh_options SSH_OPTIONS_FILE path to ssh options yml file" - puts "-e, --explain (short|long) specify result explain length(default: short)" - puts "-t, --tableformat (aa|mkd|csv|bool) specify result table type(default: aa)" - puts "-T, --tasks display the tasks with descriptions(exec rake -T)" - puts "-p, --parallel execute tasks in parallel" - puts "-1, --raketask RAKE_TASK_NAME execute specified rake task only(ex: spec:test::anyhost-01)" - puts "-h, --help show help" + puts "-s, --scenario SCENARIO_FILE path to scenario yml file" + puts "-i, --inventory INVENTORY_FILE path to ansible inventory yml file" + puts "-r, --specroot SPEC_ROOT path to spec tests root dir" + puts "-o, --ssh_options SSH_OPTIONS_FILE path to ssh options yml file" + puts "-e, --explain (short|long) specify result explain length(default: short)" + puts "-t, --tableformat (aa|mkd|csv|bool|none) specify result table type(default: aa)" + puts "-T, --tasks display the tasks with descriptions(exec rake -T)" + puts "-p, --parallel execute tasks in parallel" + puts "-P, --pattern execute pattern in spec directory" + puts "-I, --ignore-error-exit exit with 0 even on error" + puts "-a, --activate-specroot activate existed spec root only(--specroot is required)" + puts "-1, --raketask RAKE_TASK_NAME execute specified rake task only(ex: spec:test::anyhost-01)" + puts "-v, --version show version" + puts "-h, --help show help" exit 0 end end diff -Nru serverspec-runner-1.2.2/debian/changelog serverspec-runner-1.3.8/debian/changelog --- serverspec-runner-1.2.2/debian/changelog 2016-09-15 10:48:17.000000000 +0000 +++ serverspec-runner-1.3.8/debian/changelog 2019-10-11 12:52:00.000000000 +0000 @@ -1,3 +1,25 @@ +serverspec-runner (1.3.8-2) unstable; urgency=medium + + * Team upload + + * debian/control + - move to Vcs-* to salsa.debian.org + - drop "Depends: ruby-interpreter" + * debian/watch: use v4 syntax + * add debian/salsa-ci.yml to exec CI test on salsa + * add debian/gbp.conf to use git-buildpackage + + -- Hideki Yamane Fri, 11 Oct 2019 21:52:00 +0900 + +serverspec-runner (1.3.8-1) unstable; urgency=medium + + * New upstream release. + - supports ruby > 2.5 (Closes: #939645) + * New Standards-Version: 4.4.1. + * Update gemwatch url. + + -- KURASHIKI Satoru Wed, 02 Oct 2019 23:04:12 +0900 + serverspec-runner (1.2.2-1) unstable; urgency=medium * New upstream release. diff -Nru serverspec-runner-1.2.2/debian/compat serverspec-runner-1.3.8/debian/compat --- serverspec-runner-1.2.2/debian/compat 2016-09-01 11:13:41.000000000 +0000 +++ serverspec-runner-1.3.8/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru serverspec-runner-1.2.2/debian/control serverspec-runner-1.3.8/debian/control --- serverspec-runner-1.2.2/debian/control 2016-09-15 10:48:17.000000000 +0000 +++ serverspec-runner-1.3.8/debian/control 2019-10-11 12:52:00.000000000 +0000 @@ -3,23 +3,24 @@ Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: KURASHIKI Satoru -Build-Depends: debhelper (>= 9) +Build-Depends: debhelper-compat (= 12) , gem2deb , rake , ruby-net-ssh , ruby-rspec , ruby-serverspec -Standards-Version: 3.9.8 -Vcs-Git: https://github.com/lurdan/serverspec-runner.git -Vcs-Browser: https://github.com/lurdan/serverspec-runner +Standards-Version: 4.4.1 +Vcs-Git: https://salsa.debian.org/ruby-team/serverspec-runner.git +Vcs-Browser: https://salsa.debian.org/ruby-team/serverspec-runner Homepage: https://github.com/hiracy/serverspec-runner Testsuite: autopkgtest-pkg-ruby XS-Ruby-Versions: all +Rules-Requires-Root: no Package: serverspec-runner Architecture: all XB-Ruby-Versions: ${ruby:Versions} -Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter +Depends: ${shlibs:Depends}, ${misc:Depends}, ruby , ruby-serverspec , ruby-net-ssh Description: simple execution framework for serverspec @@ -27,4 +28,3 @@ recipes using one scinario yaml file, with pretty printng. In addition to that, it can export test results to other formats, like CSV, Markdown, etc. - diff -Nru serverspec-runner-1.2.2/debian/copyright serverspec-runner-1.3.8/debian/copyright --- serverspec-runner-1.2.2/debian/copyright 2016-09-01 11:13:41.000000000 +0000 +++ serverspec-runner-1.3.8/debian/copyright 2019-10-11 12:52:00.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: serverspec-runner Source: https://github.com/hiracy/serverspec-runner diff -Nru serverspec-runner-1.2.2/debian/gbp.conf serverspec-runner-1.3.8/debian/gbp.conf --- serverspec-runner-1.2.2/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ serverspec-runner-1.3.8/debian/gbp.conf 2019-10-11 12:52:00.000000000 +0000 @@ -0,0 +1,12 @@ +[DEFAULT] +debian-branch = debian/sid +upstream-tag = v%(version)s +debian-tag = debian/%(version)s +pristine-tar = True +color = auto + +[buildpackage] +# Look for a tag matching the upstream version when creating a tarball +upstream-tree = tag +# uncomment this to automatically GPG sign tags: +sign-tags = True diff -Nru serverspec-runner-1.2.2/debian/salsa-ci.yml serverspec-runner-1.3.8/debian/salsa-ci.yml --- serverspec-runner-1.2.2/debian/salsa-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ serverspec-runner-1.3.8/debian/salsa-ci.yml 2019-10-11 12:52:00.000000000 +0000 @@ -0,0 +1,8 @@ +--- +include: + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml + - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml + +variables: + SALSA_CI_DISABLE_BLHC: 1 + SALSA_CI_DISABLE_BUILD_PACKAGE_ANY: 1 diff -Nru serverspec-runner-1.2.2/debian/watch serverspec-runner-1.3.8/debian/watch --- serverspec-runner-1.2.2/debian/watch 2016-09-01 11:13:41.000000000 +0000 +++ serverspec-runner-1.3.8/debian/watch 2019-10-11 12:52:00.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 -http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/serverspec-runner .*/serverspec-runner-(.*).tar.gz +version=4 +https://gemwatch.debian.net/serverspec-runner .*/@PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ debian uupdate diff -Nru serverspec-runner-1.2.2/.gitignore serverspec-runner-1.3.8/.gitignore --- serverspec-runner-1.2.2/.gitignore 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/.gitignore 2018-12-23 23:08:20.000000000 +0000 @@ -17,3 +17,6 @@ tmp .DS_Store .rvmrc + +_platforms.yml +_serverspec_result.csv diff -Nru serverspec-runner-1.2.2/lib/serverspec-runner/ansible/inventory.rb serverspec-runner-1.3.8/lib/serverspec-runner/ansible/inventory.rb --- serverspec-runner-1.2.2/lib/serverspec-runner/ansible/inventory.rb 1970-01-01 00:00:00.000000000 +0000 +++ serverspec-runner-1.3.8/lib/serverspec-runner/ansible/inventory.rb 2018-12-23 23:08:20.000000000 +0000 @@ -0,0 +1,56 @@ +module Inventory + def self.inventory_to_platform(data) + platform = {} + + data.each do |k, v| + v.each do |gk, gv| + if gk == 'hosts' + if gv.kind_of?(Hash) + gv.each do |hk, hv| + platform[hk.to_sym] = unless hv.nil? + convert_ssh_opt(v['vars']).merge(convert_ssh_opt(hv)) + else + convert_ssh_opt(v['vars']) + end + end + elsif gv.kind_of?(Array) + gv.each do |h| + platform[h.to_sym] = convert_ssh_opt(v['vars']) + end + end + end + end + end + + platform + end + + private + + def self.convert_ssh_opt(src) + serverspec_opt = {} + serverspec_opt[:ssh_opts] = {} + src.each do |k, v| + case k + when 'ansible_host' + serverspec_opt[:host] = v + when 'ansible_user' + serverspec_opt[:ssh_opts][:user] = v + when 'ansible_port' + serverspec_opt[:ssh_opts][:port] = v + when 'ansible_ssh_private_key_file' + serverspec_opt[:ssh_opts][:keys] = Array(v) + when 'ansible_ssh_pass' + serverspec_opt[:ssh_opts][:password] = v + when 'ansible_ssh_common_args' + if v.include?('StrictHostKeyChecking=no') + serverspec_opt[:ssh_opts][:verify_host_key] = false + elsif v.include?('UserKnownHostsFile=/dev/null') + serverspec_opt[:ssh_opts][:user_known_hosts_file] = '/dev/null' + end + end + end + + serverspec_opt + end +end diff -Nru serverspec-runner-1.2.2/lib/serverspec-runner/version.rb serverspec-runner-1.3.8/lib/serverspec-runner/version.rb --- serverspec-runner-1.2.2/lib/serverspec-runner/version.rb 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/lib/serverspec-runner/version.rb 2018-12-23 23:08:20.000000000 +0000 @@ -1,3 +1,3 @@ module ServerspecRunner - VERSION = "1.2.2" + VERSION = "1.3.8" end diff -Nru serverspec-runner-1.2.2/Rakefile serverspec-runner-1.3.8/Rakefile --- serverspec-runner-1.2.2/Rakefile 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/Rakefile 2018-12-23 23:08:20.000000000 +0000 @@ -7,6 +7,7 @@ require 'open-uri' require 'serverspec-runner' require 'serverspec-runner/util/hash' +require 'serverspec-runner/ansible/inventory' desc "Run serverspec to all scenario" task :spec => 'spec:all' @@ -34,18 +35,21 @@ CSV.open(csv_file, 'w') { |w| w << ['description', 'result'] } ENV['explain'] = ENV['explain'] || "short" ENV['tableformat'] = ENV['tableformat'] || "aa" - ENV['scenario'] = ENV['scenario'] || "./scenario.yml" + ENV['scenario'] = File.expand_path(ENV['scenario'] || "./scenario.yml") + ENV['inventory'] = File.expand_path(ENV['inventory']) if ENV['inventory'] - def init_specpath(path) + def init_specpath(path, only_activate) abs_path = File::expand_path(path) - begin - print "want to create spec-tree to #{abs_path}? (y/n): " - ans = STDIN.gets.strip - exit 0 unless (ans == 'y' || ans == 'yes') - rescue Exception - exit 0 + unless only_activate + begin + print "want to create spec-tree to #{abs_path}? (y/n): " + ans = STDIN.gets.strip + exit 0 unless (ans == 'y' || ans == 'yes') + rescue Exception + exit 0 + end end FileUtils.mkdir_p("#{path}/lib") @@ -91,6 +95,8 @@ end def exec_tasks(parent, node, real_path, platform) + spec_file_pattern = ENV['pattern'] || "**/*.rb" + spec_file_exclude_pattern = ENV['exclude_pattern'] if parent == nil abs_node = node @@ -115,9 +121,11 @@ fpath = task_path.gsub(/::/, '/') if Dir.exists?("#{ENV['specpath']}/#{fpath}") - t.pattern = %W[ - #{ENV['specpath']}/#{fpath}/*.rb - ] + t.pattern = "#{ENV['specpath']}/#{fpath}/#{spec_file_pattern}" + + if spec_file_exclude_pattern + t.exclude_pattern = "#{ENV['specpath']}/#{fpath}/#{spec_file_exclude_pattern}" + end elsif File.file?("#{ENV['specpath']}/#{fpath}.rb") t.pattern = %W[ #{ENV['specpath']}/#{fpath}.rb @@ -128,6 +136,9 @@ t.fail_on_error = false ENV['TARGET_HOST'] = host_alias ENV['TARGET_SSH_HOST'] = platform[host_alias.to_sym][:host] || host_alias + if platform[host_alias.to_sym].key?(:ssh_opts) && platform[host_alias.to_sym][:ssh_opts].key?(:port) + ENV['TARGET_CONNECTION'] = 'ssh' + end end end @@ -136,7 +147,10 @@ end if !Dir.exists?(ENV['specpath']) - init_specpath(ENV['specroot']) + init_specpath(ENV['specroot'], false) + exit 0 + elsif ENV['activate_specroot'] + init_specpath(ENV['specroot'], true) exit 0 end @@ -161,21 +175,41 @@ ENV['scenario'] = ENV['scenario_tmp'] end + if !File.file?(ENV['scenario']) && !File.file?("#{ENV['specroot']}/scenario.yml") + print "\e[31m" + puts "scenario.yml is not found.(--help option can display manual))" + print "\e[m" + exit 1 + end + File.open(ENV['scenario'] || "#{ENV['specroot']}/scenario.yml") do |f| - YAML.load_documents(f).each_with_index do |data, idx| + YAML.load_stream(f).each_with_index do |data, idx| if idx == 0 scenarios = data else - data.each do |k, v| - platform[k.to_sym] = v.deep_symbolize_keys + if data != nil + data.each do |k, v| + platform[k.to_sym] = v.deep_symbolize_keys + end end end end end + if ENV['inventory'] + if !File.file?(ENV['inventory']) + print "\e[31m" + puts "inventory file is not found.(--help option can display manual))" + print "\e[m" + exit 1 + end + + platform = Inventory.inventory_to_platform(YAML.load_file(ENV['inventory'])) + end + if !scenarios print "\e[31m" - puts "scenario.yml is empty." + puts "scenario is empty." print "\e[m" exit 1 end @@ -184,8 +218,10 @@ gen_exec_plan(nil, scenarios, [], ssh_options, tasks, platform) task :stdout do + ENV['is_example_error'] = 'true' if CSV.foreach(csv_file).any? { |c| c.size > 1 && c[1] == 'NG' } - if ENV['tableformat'] == 'bool' + if ENV['tableformat'] == 'none' + elsif ENV['tableformat'] == 'bool' ret = 'ok' CSV.foreach(csv_file) do |r| @@ -250,6 +286,10 @@ end end + task :exit do + exit(1) if !ENV['ignore_error_exit'] && ENV['is_example_error'] + end + exec_tasks = [] if ENV['parallels'] processes = ENV['parallels'].to_i @@ -273,6 +313,7 @@ end exec_tasks << :stdout + exec_tasks << :exit task :all => exec_tasks # tempファイルに書き出し diff -Nru serverspec-runner-1.2.2/README.md serverspec-runner-1.3.8/README.md --- serverspec-runner-1.2.2/README.md 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/README.md 2018-12-23 23:08:20.000000000 +0000 @@ -1,7 +1,7 @@ serverspec-runner [![Gem Version](https://badge.fury.io/rb/serverspec-runner.svg)](http://badge.fury.io/rb/serverspec-runner) [![BuildStatus](https://secure.travis-ci.org/hiracy/serverspec-runner.png)](http://travis-ci.org/hiracy/serverspec-runner) ====================== -Simple execution framework for [serverspec](http://serverspec.org/). +Simple execution framework for [serverspec](http://serverspec.org/) run. ---- @@ -21,7 +21,7 @@ $ vim /path/to/your_serverspec_root/test_top_dir/.../your_serverspec_test.rb -Edit your infrastructure or middleware tests scenario to "scenario.yml". +Edit your infrastructure or middleware tests scenario to "[scenario.yml](scenario.yml)". ``` test_top_dir: # test directory top diff -Nru serverspec-runner-1.2.2/serverspec-runner.gemspec serverspec-runner-1.3.8/serverspec-runner.gemspec --- serverspec-runner-1.2.2/serverspec-runner.gemspec 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/serverspec-runner.gemspec 2018-12-23 23:08:20.000000000 +0000 @@ -20,6 +20,7 @@ spec.add_runtime_dependency "serverspec" spec.add_runtime_dependency "net-ssh" + spec.add_runtime_dependency 'psych' spec.add_development_dependency "rake" spec.add_development_dependency "rspec-core" spec.add_development_dependency "bundler", "~> 1.3" diff -Nru serverspec-runner-1.2.2/spec/example_win/default.rb serverspec-runner-1.3.8/spec/example_win/default.rb --- serverspec-runner-1.2.2/spec/example_win/default.rb 1970-01-01 00:00:00.000000000 +0000 +++ serverspec-runner-1.3.8/spec/example_win/default.rb 2018-12-23 23:08:20.000000000 +0000 @@ -0,0 +1,18 @@ +require 'spec_helper_win' + +describe command('hostname') do + its(:stdout) { should match /HOSTNAME/ } +end + +describe file('c:/windows') do + it { should be_directory } +end + +describe command('tzutil /g') do + its(:stdout) { should match /Tokyo Standard Time/ } +end + +describe windows_feature('notepad') do + it{ should be_installed } +end + diff -Nru serverspec-runner-1.2.2/spec/spec_helper.rb serverspec-runner-1.3.8/spec/spec_helper.rb --- serverspec-runner-1.2.2/spec/spec_helper.rb 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/spec/spec_helper.rb 2018-12-23 23:08:20.000000000 +0000 @@ -52,7 +52,7 @@ set_property (YAML.load_file(ENV['platforms_tmp']))[ENV['TARGET_HOST'].to_sym] - if ENV['TARGET_SSH_HOST'] !~ /localhost|127\.0\.0\.1/ + if ENV['TARGET_CONNECTION'] == 'ssh' || ENV['TARGET_SSH_HOST'] !~ /localhost|127\.0\.0\.1/ c.host = ENV['TARGET_SSH_HOST'] options = Net::SSH::Config.for(c.host, files=["~/.ssh/config"]) ssh_opts ||= ssh_opts_default diff -Nru serverspec-runner-1.2.2/spec/spec_helper_win.rb serverspec-runner-1.3.8/spec/spec_helper_win.rb --- serverspec-runner-1.2.2/spec/spec_helper_win.rb 1970-01-01 00:00:00.000000000 +0000 +++ serverspec-runner-1.3.8/spec/spec_helper_win.rb 2018-12-23 23:08:20.000000000 +0000 @@ -0,0 +1,132 @@ +require 'serverspec' +require 'pathname' +require 'net/ssh' +require 'net/ssh/proxy/command' +require 'yaml' +require 'csv' +require 'serverspec-runner/util/hash' +require 'winrm' + +# require extension libraries +Dir.glob([ + ENV['specroot'] + '/lib/extension/serverspec/**/*.rb', + ENV['specroot'] + '/lib/extension/specinfra/**/*.rb']).each {|f| require f} + +ssh_opts_default = YAML.load_file(ENV['ssh_options']) +csv_path = ENV['result_csv'] +explains = [] +results = [] +row_num = [] +spacer_char = ' ' unless ENV['tableformat'] == 'csv' +spacer_char = ',' if ENV['tableformat'] == 'csv' + +def get_example_desc(example_group, descriptions) + + descriptions << example_group[:description] + return descriptions if example_group[:parent_example_group] == nil + + get_example_desc(example_group[:parent_example_group], descriptions) +end + +RSpec.configure do |c| + + c.expose_current_running_example_as :example + c.path = ENV['EXEC_PATH'] + + run_path = c.files_to_run[0].split('/') + + speck_i = 0 + run_path.reverse.each_with_index do |r,i| + if r == 'spec' + speck_i = ((run_path.size - 1) - i) + end + end + sliced = run_path.slice((speck_i + 1)..(run_path.size - 2)) + role_name = sliced.join('/') + + if ENV['ASK_SUDO_PASSWORD'] + require 'highline/import' + c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false } + else + c.sudo_password = ENV['SUDO_PASSWORD'] + end + + set_property (YAML.load_file(ENV['platforms_tmp']))[ENV['TARGET_HOST'].to_sym] + + if ENV['TARGET_SSH_HOST'] !~ /localhost|127\.0\.0\.1/ + c.host = ENV['TARGET_SSH_HOST'] + options = Net::SSH::Config.for(c.host, files=["~/.ssh/config"]) + ssh_opts ||= ssh_opts_default + property[:ssh_opts].each { |k, v| ssh_opts[k.to_sym] = v } if property[:ssh_opts] + ssh_opts[:proxy] = Kernel.eval(ssh_opts[:proxy]) if ssh_opts[:proxy] + user = options[:user] || ssh_opts[:user] || Etc.getlogin + options.merge!(ssh_opts) + set :ssh_options, options + set :backend, :ssh + set :request_pty, true + else + set :backend, :exec + end + + prev_desc_hierarchy = nil + + c.before(:suite) do + entity_host = (((ENV['TARGET_HOST'] != ENV['TARGET_SSH_HOST']) && (ENV['TARGET_SSH_HOST'] != nil)) ? "(#{ENV['TARGET_SSH_HOST']})" : "") + puts "\e[33m" + puts "### start [#{role_name}@#{ENV['TARGET_HOST']}] #{entity_host} serverspec... ###" + print "\e[m" + + explains << "#{role_name}@#{ENV['TARGET_HOST']}#{entity_host}" + results << "" + row_num << 1 + end + + c.after(:each) do + + if ENV['explain'] == 'long' + explains << spacer_char + example.metadata[:full_description] + results << (self.example.exception ? 'NG' : 'OK') + row_num << 1 + else + + spacer = '' + desc_hierarchy = get_example_desc(self.example.metadata[:example_group], []).reverse + desc_hierarchy.each_with_index do |ex, i| + spacer += spacer_char + + if prev_desc_hierarchy != nil && prev_desc_hierarchy.length > i && prev_desc_hierarchy[i] == desc_hierarchy[i] + else + explains << spacer + ex + results << '' + row_num << i + 1 + end + end + + explains << spacer + spacer_char + (self.example.metadata[:description] || '') + results << (self.example.exception ? 'NG' : 'OK') + row_num << desc_hierarchy.length + 1 + + prev_desc_hierarchy = desc_hierarchy + end + end + + c.after(:suite) do + CSV.open(csv_path, 'a') do |writer| + explains.each_with_index do |v, i| + writer << [v, results[i], row_num[i]] + end + end + end +end + +set :backend, :winrm + +opts = { + user: "Username", # ex.) Administrator + password: "Password", # connection password + endpoint: "http://IPaddress:5985/wsman", + operation_timeout: 300, +} + +winrm = WinRM::Connection.new(opts) +Specinfra.configuration.winrm = winrm diff -Nru serverspec-runner-1.2.2/.travis.yml serverspec-runner-1.3.8/.travis.yml --- serverspec-runner-1.2.2/.travis.yml 2015-11-06 07:00:08.000000000 +0000 +++ serverspec-runner-1.3.8/.travis.yml 2018-12-23 23:08:20.000000000 +0000 @@ -1,13 +1,14 @@ language: ruby rvm: - - 1.9.3 +# - 1.9.3 - 2.0.0 - 2.1.5 - 2.2.0 + - 2.5.1 before_install: - gem update bundler script: - - bundle exec rake spec + - bundle exec rake spec -I