From dff18bac1b91074cd44a4f3fe02285e7f4ecb838 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 19 Aug 2020 15:36:17 -0700 Subject: [PATCH] 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 --- playbooks/zuul/infra-puppet-beaker-rspec/pre.yaml | 3 +++ playbooks/zuul/infra-puppet-beaker-rspec/run.yaml | 8 +++++++- zuul.d/puppet.yaml | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 playbooks/zuul/infra-puppet-beaker-rspec/pre.yaml diff --git a/playbooks/zuul/infra-puppet-beaker-rspec/pre.yaml b/playbooks/zuul/infra-puppet-beaker-rspec/pre.yaml new file mode 100644 index 0000000000..3e47b9a706 --- /dev/null +++ b/playbooks/zuul/infra-puppet-beaker-rspec/pre.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - role: ensure-virtualenv diff --git a/playbooks/zuul/infra-puppet-beaker-rspec/run.yaml b/playbooks/zuul/infra-puppet-beaker-rspec/run.yaml index 5d9adb0361..9e75c489ec 100644 --- a/playbooks/zuul/infra-puppet-beaker-rspec/run.yaml +++ b/playbooks/zuul/infra-puppet-beaker-rspec/run.yaml @@ -15,7 +15,13 @@ 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 "" + 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 diff --git a/zuul.d/puppet.yaml b/zuul.d/puppet.yaml index d2d64a17b2..5f034e4649 100644 --- a/zuul.d/puppet.yaml +++ b/zuul.d/puppet.yaml @@ -86,6 +86,7 @@ description: | Base job for beaker-rspec tests for Infra's puppet modules. nodeset: ubuntu-xenial + pre-run: playbooks/zuul/infra-puppet-beaker-rspec/pre.yaml run: playbooks/zuul/infra-puppet-beaker-rspec/run.yaml vars: nodeset: nodepool-xenial