diff --git a/lib/puppet-openstack_infra_spec_helper/spec_helper_acceptance.rb b/lib/puppet-openstack_infra_spec_helper/spec_helper_acceptance.rb index f63d71d..d13ba17 100755 --- a/lib/puppet-openstack_infra_spec_helper/spec_helper_acceptance.rb +++ b/lib/puppet-openstack_infra_spec_helper/spec_helper_acceptance.rb @@ -1,53 +1,54 @@ require 'beaker-rspec' -SYSTEM_CONFIG='openstack-infra/system-config' +SYSTEM_CONFIG='git.openstack.org/openstack-infra/system-config' def install_infra_puppet(host) - # puppet 3 isn't available from apt.puppetlabs.com so install it from the Xenial repos - on host, "which apt-get && apt-get install puppet -y", { :acceptable_exit_codes => [0,1] } - # otherwise use the beaker helpers to install the yum.puppetlabs.com repo and puppet - r = on host, "which yum", { :acceptable_exit_codes => [0,1] } - if r.exit_code == 0 - install_puppet - end + install_system_config(host) + on host, "bash -x #{ENV['HOME']}/src/#{SYSTEM_CONFIG}/install_puppet.sh", :environment => ENV.to_hash end def setup_host(host) add_platform_foss_defaults(host, 'unix') - on host, "mkdir -p #{host['distmoduledir']}" -end - -def install_system_config(host) - # install git - install_package host, 'git' - - # Install dependent modules via git or zuul - on host, "rm -fr #{SYSTEM_CONFIG}" - if ENV['ZUUL_UUID'] - zuul_clone_cmd = '/usr/zuul-env/bin/zuul-cloner ' - zuul_clone_cmd += '--cache-dir /opt/git ' - zuul_clone_cmd += "git://git.openstack.org #{SYSTEM_CONFIG}" - on host, zuul_clone_cmd, :environment => ENV.to_hash - else - on host, "git clone https://git.openstack.org/#{SYSTEM_CONFIG} #{SYSTEM_CONFIG}" + if ENV['PUPPET_VERSION'] == '4' + host.ssh_permit_user_environment() + host.add_env_var('PATH', '/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/:/opt/puppetlabs/bin') + # The SSH connection needs to be closed in order to refresh the SSH environment changes. + # It will reopen the next time a host action starts. + host.close end end +def install_system_config(host) + install_package host, 'git' + on host, "test -d #{ENV['HOME']}/src/#{SYSTEM_CONFIG} || git clone https://#{SYSTEM_CONFIG} #{ENV['HOME']}/src/#{SYSTEM_CONFIG}" +end + def install_infra_modules(host, proj_root) - install_system_config(host) # Clean out any module cruft - shell('rm -fr /etc/puppet/modules/*') + if ENV['PUPPET_VERSION'] == '4' + on host, 'rm -fr /etc/puppetlabs/code/modules/*' + else + on host, 'rm -fr /etc/puppet/modules/*' + end # Install module and dependencies modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1] - module_install_cmd = "bash #{SYSTEM_CONFIG}/tools/install_modules_acceptance.sh" + module_install_cmd = "bash #{ENV['HOME']}/src/#{SYSTEM_CONFIG}/tools/install_modules_acceptance.sh" on host, module_install_cmd, :environment => ENV.to_hash - on host, "rm -fr /etc/puppet/modules/#{modname}" + if ENV['PUPPET_VERSION'] == '4' + on host, "rm -fr /etc/puppetlabs/code/modules/#{modname}" + else + on host, "rm -fr /etc/puppet/modules/#{modname}" + end # Install the module being tested - puppet_module_install(:source => proj_root, :module_name => modname) + opts = {:source => proj_root, :module_name => modname} + if ENV['PUPPET_VERSION'] == '4' + opts[:target_module_path] = '/etc/puppetlabs/code/modules' + end + puppet_module_install(opts) # List modules installed to help with debugging - on hosts[0], puppet('module','list'), { :acceptable_exit_codes => 0 } + on host, puppet('module','list'), { :acceptable_exit_codes => 0 } end proj_root = File.expand_path(File.join(Dir.getwd)) @@ -64,7 +65,7 @@ end # Set up hosts, before running any tests hosts.each do |host| - install_infra_puppet(host) setup_host(host) + install_infra_puppet(host) install_infra_modules(host, proj_root) end