diff --git a/Gemfile b/Gemfile index 212a3038..22a1f39f 100644 --- a/Gemfile +++ b/Gemfile @@ -13,8 +13,10 @@ gem 'simp-build-helpers' gem 'simp-beaker-helpers' gem 'beaker-puppet_install_helper' gem 'rake', '>= 12.3.3' -gem 'beaker-docker', :git => 'https://github.com/trevor-vaughan/beaker-docker', :branch => 'support_rootless_podman' -gem 'docker-api', :git => 'https://github.com/trevor-vaughan/docker-api', :branch => 'podman-compat' +# You'll need the following if using podman until they are released upstream +#gem 'beaker-docker', :git => 'https://github.com/trevor-vaughan/beaker-docker', :branch => 'support_rootless_podman' +#gem 'docker-api', :git => 'https://github.com/trevor-vaughan/docker-api', :branch => 'podman-compat' +gem 'beaker-docker' if puppetversion gem 'puppet', puppetversion diff --git a/lib/simp/local_gpg_signing_key.rb b/lib/simp/local_gpg_signing_key.rb index 23744e52..edcdb2d3 100644 --- a/lib/simp/local_gpg_signing_key.rb +++ b/lib/simp/local_gpg_signing_key.rb @@ -83,6 +83,8 @@ def initialize(dir = 'dev', opts = {}) # @return [Gem::Version] def gpg_version return @gpg_version if @gpg_version + + which('gpg', true) @gpg_version = %x{gpg --version}.lines.first.split(/\s+/).last unless @gpg_version.nil? || @gpg_version.empty? @@ -113,6 +115,8 @@ def gpg_agent_info def dev_key_days_left ensure_gpg_directory days_left = 0 + + which('gpg', true) current_key = %x(GPG_AGENT_INFO='' gpg --homedir=#{@dir} --list-keys #{@key_email} 2>/dev/null) unless current_key.empty? lasts_until = current_key.lines.first.strip.split("\s").last.delete(']') @@ -179,6 +183,10 @@ def ensure_key generate_key(agent_info[:info]) else + which('gpg', true) + which('gpg-agent', true) + which('gpg-connect-agent', true) + # Start the GPG agent %x{gpg-agent --homedir=#{Dir.pwd} >&/dev/null || gpg-agent --homedir=#{Dir.pwd} --daemon >&/dev/null} @@ -240,6 +248,8 @@ def kill_agent(pid) # @param gpg_agent_info_str [String] value to set the GPG_AGENT_INFO # environment variable to use in order to use the correct `gpg-agent`. def generate_key(gpg_agent_info_str) + which('gpg', true) + puts "Generating new GPG key#{@verbose ? " under '#{@dir}'" : ''}..." gpg_cmd = %(GPG_AGENT_INFO=#{gpg_agent_info_str} gpg --homedir="#{@dir}") @@ -298,13 +308,16 @@ def write_genkey_parameter_file # Write a local gpg-agent daemon script file def write_gpg_agent_startup_script + which('gpg-agent', true) + pinentry_cmd = which('pinentry-curses', true) + gpg_agent_script = <<-AGENT_SCRIPT.gsub(%r{^ {20}}, '') #!/bin/sh gpg-agent --homedir=#{Dir.pwd} --daemon \ --no-use-standard-socket --sh --batch \ --write-env-file "#{@gpg_agent_env_file}" \ - --pinentry-program /usr/bin/pinentry-curses < /dev/null & + --pinentry-program #{pinentry_cmd} < /dev/null & AGENT_SCRIPT File.open(@gpg_agent_script, 'w') { |fh| fh.puts(gpg_agent_script) } diff --git a/lib/simp/rake.rb b/lib/simp/rake.rb index 2fa6e25f..4480713a 100644 --- a/lib/simp/rake.rb +++ b/lib/simp/rake.rb @@ -96,14 +96,21 @@ def run_pager exec pager rescue exec "/bin/sh", "-c", pager end - # Originally snarfed from - # http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby - def which(cmd) - command = Facter::Core::Execution.which(cmd) + def which(cmd, fail=false) + @which_cache ||= {} - warn "Warning: Command #{cmd} not found on the system." unless command + if @which_cache.has_key?(cmd) + command = @which_cache[cmd] + else + command = Facter::Core::Execution.which(cmd) + @which_cache[cmd] = command + end + + msg = "Warning: Command #{cmd} not found on the system." + + fail ? raise(msg) : warn(msg) unless command - return command + command end def help diff --git a/lib/simp/rake/helpers/version.rb b/lib/simp/rake/helpers/version.rb index b78411ae..e2214ede 100644 --- a/lib/simp/rake/helpers/version.rb +++ b/lib/simp/rake/helpers/version.rb @@ -2,5 +2,5 @@ module Simp; end module Simp::Rake; end class Simp::Rake::Helpers - VERSION = '5.11.5' + VERSION = '5.11.6' end diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 2c026646..e36b19cb 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -5,36 +5,17 @@ HOSTS: - build_server platform: el-7-x86_64 hypervisor: docker - image: centos:7 + image: simpproject/simp_build_centos7 docker_cmd: '/usr/sbin/sshd -D -E /var/log/sshd.log' - mount_folders: - folder1: - host_path: ./ - container_path: /host_files - docker_preserve_image: true - ssh: - password: root - auth_methods: - - password el8-build-server: roles: - build_server platform: el-8-x86_64 hypervisor: docker - image: centos:8 + image: simpproject/simp_build_centos8 docker_cmd: '["/sbin/init"]' - docker_cap_add: - - AUDIT_WRITE - mount_folders: - folder1: - host_path: ./ - container_path: /host_files docker_preserve_image: true - ssh: - password: root - auth_methods: - - password CONFIG: log_level: verbose @@ -44,3 +25,15 @@ CONFIG: <% else -%> puppet_collection: puppet6 <% end -%> + ssh: + password: root + auth_methods: + - password + docker_cap_add: + - AUDIT_WRITE + docker_preserve_image: true + mount_folders: + host_files: + host_path: ./ + container_path: /host_files + opts: 'z' diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index b4aedb9b..58310e85 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,22 +1,35 @@ require 'beaker-rspec' +require 'tmpdir' +require 'yaml' require 'simp/beaker_helpers' include Simp::BeakerHelpers -require 'tmpdir' -require 'pry' if ENV['PRY'] == 'yes' require 'acceptance/support/simp_rake_helpers' $LOAD_PATH.unshift(File.expand_path('../acceptance/support',__FILE__)) +unless ENV['BEAKER_provision'] == 'no' + hosts.each do |host| + # Install Puppet + if host.is_pe? + install_pe + else + install_puppet + end + end +end + RSpec.configure do |c| # provide helper methods to individual examples AND example groups c.include Simp::BeakerHelpers::SimpRakeHelpers c.extend Simp::BeakerHelpers::SimpRakeHelpers + # ensure that environment OS is ready on each host + fix_errata_on hosts + # Readable test descriptions c.formatter = :documentation - # Configure all nodes in nodeset c.before :suite do end end