| |
@@ -1,266 +0,0 @@
|
| |
- ---
|
| |
- - name: Install the Ansible and RHTS pre-requirements
|
| |
- package: name={{item}} state=latest
|
| |
- with_items:
|
| |
- - rsync # need rsync for Ansible synchronize module
|
| |
- - dnf-plugins-core # need COPR plugin
|
| |
- - openssh-server
|
| |
- - beakerlib
|
| |
- - make
|
| |
- - createrepo
|
| |
-
|
| |
- - name: Enable COPR repo for restraint
|
| |
- shell: dnf copr -y enable bpeck/restraint
|
| |
- ignore_errors: True
|
| |
-
|
| |
- - name: Enable COPR repo for beakerlib-libraries
|
| |
- shell: dnf copr -y enable mvadkert/beakerlib-libraries
|
| |
- ignore_errors: True
|
| |
- when: use_beakerlib_libraries
|
| |
-
|
| |
- - name: Install restraint from COPR repo
|
| |
- package: name={{item}} state=latest
|
| |
- with_items:
|
| |
- - restraint
|
| |
- - restraint-rhts
|
| |
- - restraint-client
|
| |
-
|
| |
- - name: Install beakerlib libraries from mvadkert/beakerlib-libraries COPR repo
|
| |
- package: name={{item}} state=latest
|
| |
- with_items:
|
| |
- - beakerlib-libraries
|
| |
- when: use_beakerlib_libraries
|
| |
-
|
| |
- - name: Install any test-specific package requirements
|
| |
- package: name={{item}} state=latest
|
| |
- with_items:
|
| |
- - "{{ required_packages }}"
|
| |
-
|
| |
- - name: Fetch tests from remote repositories
|
| |
- git:
|
| |
- repo: "{{ item.repo }}"
|
| |
- dest: "{{ item.dest }}"
|
| |
- version: "{{ item.version | default('master') }}"
|
| |
- with_items:
|
| |
- "{{ repositories }}"
|
| |
- when: repositories is defined
|
| |
-
|
| |
- - name: Define remote_artifacts if it is not already defined
|
| |
- set_fact:
|
| |
- remote_artifacts: /tmp/artifacts
|
| |
- when: remote_artifacts is not defined
|
| |
-
|
| |
- - name: Create legacy beakerlib directories
|
| |
- file:
|
| |
- dest: "{{ item }}"
|
| |
- state: directory
|
| |
- with_items:
|
| |
- - /usr/lib/beakerlib
|
| |
- - /usr/share/rhts-library
|
| |
-
|
| |
- - name: Create legacy beakerlib links
|
| |
- file:
|
| |
- src: /usr/share/beakerlib/beakerlib.sh
|
| |
- dest: "{{ item }}"
|
| |
- state: link
|
| |
- with_items:
|
| |
- - /usr/lib/beakerlib/beakerlib.sh
|
| |
- - /usr/share/rhts-library/rhtslib.sh
|
| |
-
|
| |
- - name: Create RPM repo directory
|
| |
- file:
|
| |
- dest: "{{ repo_dir }}"
|
| |
- state: directory
|
| |
-
|
| |
- - name: Initialize RPM list
|
| |
- set_fact:
|
| |
- my_rpm_list: []
|
| |
-
|
| |
- - name: Split 'rpms' argument into a list
|
| |
- set_fact:
|
| |
- my_rpm_list: "{{ rpms.split(' ') | unique }}"
|
| |
- when: rpms is defined and rpms|length > 0
|
| |
-
|
| |
- - name: Copy RPMs to target
|
| |
- copy:
|
| |
- src: "{{ item }}"
|
| |
- dest: "{{ repo_dir }}/"
|
| |
- with_items:
|
| |
- - "{{ my_rpm_list }}"
|
| |
-
|
| |
- - name: Generate RPM repo metadata
|
| |
- shell: createrepo "{{ repo_dir }}"
|
| |
-
|
| |
- - name: Add RPM repo
|
| |
- yum_repository:
|
| |
- name: local
|
| |
- description: local repo
|
| |
- baseurl: "file://{{ repo_dir }}"
|
| |
- gpgcheck: no
|
| |
-
|
| |
- - name: Set list of SRPMs
|
| |
- set_fact:
|
| |
- my_srpm_list: "{{ my_rpm_list
|
| |
- | map('regex_search', '^.*\\.src\\.rpm$')
|
| |
- | select('string') | list }}"
|
| |
-
|
| |
- - name: Set list of non-SRPMs
|
| |
- set_fact:
|
| |
- my_nonsrpm_list: "{{ my_rpm_list | difference(my_srpm_list) }}"
|
| |
-
|
| |
- - name: Map non-SRPMs to target paths to be installed
|
| |
- set_fact:
|
| |
- my_install_rpm_list: "{{ my_nonsrpm_list | map('basename')
|
| |
- | map('regex_replace', '^', repo_dir ~ '/')
|
| |
- | list }}"
|
| |
-
|
| |
- - name: Install RPMs
|
| |
- shell: dnf install -y {{ my_install_rpm_list | join(' ') }}
|
| |
- when: my_install_rpm_list|length > 0
|
| |
-
|
| |
- - name: Create tests directory
|
| |
- file:
|
| |
- dest: "{{ test_dir }}"
|
| |
- state: directory
|
| |
-
|
| |
- - name: Copy tests to target
|
| |
- synchronize:
|
| |
- src: "{{ playbook_dir }}/{{ item }}"
|
| |
- dest: "{{ test_dir }}/"
|
| |
- recursive: yes
|
| |
- ssh_args: "-o UserKnownHostsFile=/dev/null"
|
| |
- with_items:
|
| |
- - "{{ tests }}"
|
| |
-
|
| |
- - block:
|
| |
- - name: Resolve test dependencies of beakerlib libraries
|
| |
- script: "{{ role_path }}/files/resolve-test-dependencies {{ test_dir }}/{{ item }}"
|
| |
- with_items:
|
| |
- - "{{ tests }}"
|
| |
- register: deps
|
| |
- environment:
|
| |
- BEAKERLIB_LIBRARY_PATH: /usr/share/beakerlib-libraries
|
| |
-
|
| |
- - name: Install required packages from RhtsRequires
|
| |
- package: name={{ item }} state=latest
|
| |
- with_items:
|
| |
- - "{{ deps.results[0].stdout_lines[0].split() }}"
|
| |
-
|
| |
- - name: Install packages from Requires, skip those not available packages
|
| |
- command: dnf -y install --skip-broken {{ deps.results[0].stdout_lines[1] }}
|
| |
- when: deps.results[0].stdout_lines[1].strip() != ""
|
| |
-
|
| |
- when: use_beakerlib_libraries
|
| |
-
|
| |
- - name: Generate test archives for restraint
|
| |
- shell: tar czf "{{ test_dir }}/{{ item | basename }}.tgz" -C "{{ test_dir }}" "{{ item | basename }}"
|
| |
- with_items:
|
| |
- - "{{ tests }}"
|
| |
-
|
| |
- - name: Generate restraint job XML file
|
| |
- template:
|
| |
- # template references variables 'tests' and 'local_www_port'
|
| |
- src: job.xml.j2
|
| |
- dest: "{{ job_xml_file }}"
|
| |
-
|
| |
- - name: Copy restraint results conversion stylesheet to target
|
| |
- copy:
|
| |
- src: job2text.xsl
|
| |
- dest: /usr/local/share/
|
| |
-
|
| |
- - name: Create root SSH directory
|
| |
- 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: Create root SSH public key
|
| |
- shell: ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub
|
| |
- args:
|
| |
- creates: /root/.ssh/id_rsa.pub
|
| |
-
|
| |
- - 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
|
| |
- 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: Make artifacts directory
|
| |
- file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes
|
| |
-
|
| |
- - name: Start restraintd
|
| |
- # instead of using service module, daemon is started directly since we want the
|
| |
- # output as an artifact (and this could be running in a container)
|
| |
- shell: nohup /usr/bin/restraintd >"{{ remote_artifacts }}/restraintd.log" 2>&1 &
|
| |
-
|
| |
- - name: Start local web server for restraint
|
| |
- shell: nohup /usr/bin/python -m SimpleHTTPServer "{{ local_www_port }}" >"{{ remote_artifacts }}/httpd.log" 2>&1 &
|
| |
- args:
|
| |
- chdir: "{{ local_www_dir }}/"
|
| |
-
|
| |
- - block:
|
| |
- - name: Execute RHTS tests using restraint
|
| |
- shell: /usr/bin/restraint --host localhost --job "{{ job_xml_file }}" >"{{ remote_artifacts }}/restraint.log" 2>&1
|
| |
- args:
|
| |
- chdir: "{{ remote_artifacts }}/"
|
| |
- ignore_errors: True
|
| |
- register: restraint_result
|
| |
-
|
| |
- - always:
|
| |
- - name: Extract job output directory from restraint logfile
|
| |
- shell: sed -n 's/^Using \([^ ]*\).*$/\1/p' "{{ remote_artifacts }}/restraint.log"
|
| |
- register: restraint_job_dir
|
| |
-
|
| |
- - name: Make job ouput directory tree readable by all
|
| |
- file:
|
| |
- path: "{{ remote_artifacts }}/{{restraint_job_dir.stdout}}"
|
| |
- mode: u=rwX,g=rX,o=rX
|
| |
- recurse: yes
|
| |
-
|
| |
- - name: Set name of restraint XML job results file
|
| |
- set_fact: results_xml="{{ remote_artifacts }}/{{restraint_job_dir.stdout}}/job.xml"
|
| |
-
|
| |
- - name: Convert restraint XML job results to text as main output artifact
|
| |
- shell: xsltproc /usr/local/share/job2text.xsl "{{ results_xml }}" >"{{ remote_artifacts }}/test.log"
|
| |
-
|
| |
- - name: Pull out the logs
|
| |
- synchronize:
|
| |
- dest: "{{ artifacts }}/"
|
| |
- src: "{{ remote_artifacts }}/"
|
| |
- mode: pull
|
| |
- ssh_args: "-o UserKnownHostsFile=/dev/null"
|
| |
- when: artifacts|default("") != ""
|
| |
-
|
| |
- - name: Check the results for failures
|
| |
- shell: egrep '^(FAIL|WARN|None) ' "{{ remote_artifacts }}/test.log"
|
| |
- register: test_fails
|
| |
- failed_when: test_fails.stdout or test_fails.stderr or restraint_result.rc != 0
|
| |
standard-test-rhts had next defects:
All this were confusing. beakerlib-libraries now supported by
standard-test-beakerlib role.
Signed-off-by: Andrei Stepanov astepano@redhat.com