puppet-openstack-integration/playbooks/run-beaker-tests.yaml
Takashi Kajinami 0be086fef5 Explicitly set --bindir when isntalling bundle
... so that we can make sure that bundle command is installed in
GEM_HOME/bin directory.

Change-Id: I1ea78bbd2b7fe22d510e10b0c96c0ed7bdc9f8a3
Closes-Bug: #1866176
2020-03-10 06:09:34 +00:00

71 lines
3.0 KiB
YAML

- hosts: all
tasks:
- name: Prepare ssh config on the host to run beaker
shell:
cmd: |
echo "" | sudo tee -a /etc/ssh/sshd_config
echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
echo " PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
echo "" | sudo tee -a /etc/ssh/sshd_config
echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
echo " PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
mkdir -p .ssh
ssh-keygen -f ~/.ssh/id_rsa -b 2048 -P ""
sudo mkdir -p /root/.ssh
cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
if [[ -f /usr/bin/yum || -f /usr/bin/dnf ]]; then
sudo systemctl reload sshd
elif [ -f /usr/bin/apt-get ]; then
sudo service ssh restart
fi
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- name: Run beaker
shell:
cmd: |
trap "{{ ansible_user_dir }}/workspace/puppet-openstack-integration/copy_logs.sh" EXIT
if [ "{{ puppet_gem_version }}" != "latest" ]; then
export PUPPET_GEM_VERSION='~> {{ puppet_gem_version }}'
fi
export BEAKER_PUPPET_COLLECTION=puppet5
export BEAKER_set=nodepool-{{ nodepool_type }}
export BEAKER_debug=yes
export BEAKER_color=no
if [ -f Modulefile -o -f metadata.json ]; then
if [ -f Modulefile ]; then
MODULE=$(awk '/^name/ {print $NF}' Modulefile |tr -d \"\')
elif [ -f metadata.json ]; then
MODULE=$(python -c 'import json;print json.load(open("metadata.json"))["name"]')
fi
if [ -z "$MODULE" ]; then
echo "Module name not defined in Modulefile or metadata.json"
else
mkdir -p "$MODULE"
rsync -a --exclude="$MODULE" --exclude ".*" . "$MODULE"
cd "$MODULE"
fi
fi
mkdir .bundled_gems
export GEM_HOME=`pwd`/.bundled_gems
export GEM_BIN_DIR=$GEM_HOME/bin
if [ -f Gemfile ]; then
ruby <<EOF
cmd = 'gem install bundler --no-rdoc --no-ri --verbose --no-user-install --bindir=${GEM_BIN_DIR}'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3.0') then
cmd += ' -v 1.17.3'
end
system(cmd)
EOF
$GEM_BIN_DIR/bundle install --without system_tests --retry 3
$GEM_BIN_DIR/bundle exec rspec spec/acceptance
else
gem install rake -n ./.bundled_gems/ --no-user-instal
gem install beaker-rspec --no-user-install
gem install puppetlabs_spec_helper --no-user-install
./.bundled_gems/rake acceptance 2>&1 --no-user-install
fi
chdir: '{{ ansible_user_dir }}/workspace'
executable: /bin/bash
environment: '{{ zuul | zuul_legacy_vars }}'