Class: Busser::RunnerPlugin::Testinfra
- Inherits:
-
Base
- Object
- Base
- Busser::RunnerPlugin::Testinfra
- Defined in:
- lib/busser/runner_plugin/testinfra.rb
Overview
A Busser runner plugin for testinfra
Instance Method Summary collapse
Instance Method Details
#install_testinfra ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/busser/runner_plugin/testinfra.rb', line 21 def install_testinfra exe = find_executable0 "testinfra", nil if exe.nil? ("Installing testinfra...") if linux_variant[:family] == "RedHat" run("pip install setuptools==20.6.7") end run("pip install testinfra") end end |
#linux_variant ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/busser/runner_plugin/testinfra.rb', line 33 def linux_variant r = { :distro => nil, :family => nil } if File.exist?("/etc/lsb-release") File.open("/etc/lsb-release", "r").read.each_line do |line| r = { :distro => $1 } if line =~ /^DISTRIB_ID=(.*)/ end end if File.exist?("/etc/debian_version") r[:distro] = "Debian" if r[:distro].nil? r[:family] = "Debian" if r[:variant].nil? elsif File.exist?("/etc/redhat-release") || File.exist?("/etc/centos-release") r[:family] = "RedHat" if r[:family].nil? r[:distro] = "CentOS" if File.exist?("/etc/centos-release") elsif File.exist?("/etc/SuSE-release") r[:distro] = "SLES" if r[:distro].nil? end return r end |
#test ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/busser/runner_plugin/testinfra.rb', line 12 def test install_testinfra Dir.glob("#{suite_path("testinfra")}/test_*.py").each do |file| "[testinfra] #{File.basename(file)}" run!("testinfra --verbose #{file}") end end |