system-config/playbooks/zuul/infra-puppet-beaker-rspec/run.yaml
Clark Boylan dff18bac1b Convert ssh keys for ruby net-ssh if necessary
In our beaker rspec testing we ssh into localhost pretending it is a
managed VM because that is how all the config management testing tools
want to work... This is has run into problems with new format ssh keys
which zuul provides. If such a key is present we convert it to PEM
othrewise we generate our own.

Also add ensure-virtualenv to the job as we appear to need it to run
these tests properly.

Change-Id: Ibb6080b5a321a6955866ef9b847c4d00da17f427
2020-08-19 16:28:08 -07:00

61 lines
2.1 KiB
YAML

- hosts: all
name: Beaker-rspec functional testing for Infra puppet modules
roles:
- bindep
tasks:
- name: Set up SSH for 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
if [ -f ~/.ssh/id_rsa ] ; then
# A key already exists, we'll use it but ensure it is in pem
# format for ruby's net-ssh
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa -N '' -P ''
else
ssh-keygen -f ~/.ssh/id_rsa -b 2048 -P ""
fi
sudo mkdir -p /root/.ssh
cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
if [ -f /usr/bin/yum ]; then
sudo systemctl reload sshd
elif [ -f /usr/bin/apt-get ]; then
sudo service ssh restart
fi
- name: Create local gems directory
file:
state: directory
path: '{{ ansible_user_dir }}/.bundled_gems'
- name: Install ruby dependencies
become: yes
shell:
cmd: |
if [ -f /usr/bin/yum ]; then
yum install ruby-devel gcc-c++ -y
elif [ -f /usr/bin/apt-get ]; then
apt-get install ruby-dev -y
fi
- name: Execute acceptance tests
shell:
cmd: |
gem install bundler --no-ri --no-rdoc --verbose --version '<2.0.0'
$GEM_HOME/bin/bundle install --retry 3
export BEAKER_set={{ nodeset }}
export BEAKER_debug=yes
export BEAKER_color=no
$GEM_HOME/bin/bundle exec rspec spec/acceptance
chdir: "{{ project_src_dir }}"
environment:
'GEM_HOME': "{{ ansible_user_dir }}/.bundled_gems"
'PUPPET_VERSION': "{{ puppet_version | default('4') }}"