From ef8f114ef852f9ca1c512d0a57c69b2717d0246b Mon Sep 17 00:00:00 2001 From: Merlin Mathesius Date: Jul 25 2017 15:49:34 +0000 Subject: Update standard-test-rhts role to make it compatible with containers started by the standard-inventory-docker. Specifically, SSHD needs to be installed, configured, and started if it hasn't already. --- diff --git a/roles/standard-test-rhts/tasks/main.yml b/roles/standard-test-rhts/tasks/main.yml index 1d9586c..873eda2 100644 --- a/roles/standard-test-rhts/tasks/main.yml +++ b/roles/standard-test-rhts/tasks/main.yml @@ -4,6 +4,7 @@ with_items: - rsync # need rsync for Ansible synchronize module - dnf-plugins-core # need COPR plugin + - openssh-server - beakerlib - make - createrepo @@ -128,16 +129,42 @@ file: dest: /root/.ssh state: directory + mode: 0700 - name: Create root SSH key pair shell: ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa args: creates: /root/.ssh/id_rsa +- name: Procure root public key + shell: cat /root/.ssh/id_rsa.pub + register: my_pub_key_output + - name: Configure password-less local SSH for restraint - shell: | - cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys - chmod 644 /root/.ssh/authorized_keys + authorized_key: + user: root + state: present + key: "{{ my_pub_key_output.stdout }}" + +- name: Check if SSHD is running + wait_for: port=22 search_regex=OpenSSH timeout=3 + ignore_errors: true + register: sshd_check + +- block: # SSHD not running; configure and start it + + - name: Create host SSH key pair + shell: ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key + args: + creates: /etc/ssh/ssh_host_rsa_key + + - name: Start SSHD in background + shell: /usr/sbin/sshd + + - name: Wait for SSHD to start + wait_for: port=22 search_regex=OpenSSH + + when: sshd_check|failed - name: Clear artifacts directory file: path={{ remote_artifacts }} state=absent