system-config/playbooks/zuul/run-base-post.yaml
Ian Wienand d4c46ecdef
Abstract name of bastion host for testing path
This replaces hard-coding of the host "bridge.openstack.org" with
hard-coding of the first (and only) host in the group "bastion".

The idea here is that we can, as much as possible, simply switch one
place to an alternative hostname for the bastion such as
"bridge.opendev.org" when we upgrade.  This is just the testing path,
for now; a follow-on will modify the production path (which doesn't
really get speculatively tested)

This needs to be defined in two places :

 1) We need to define this in the run jobs for Zuul to use in the
    playbooks/zuul/run-*.yaml playbooks, as it sets up and collects
    logs from the testing bastion host.

 2) The nested Ansible run will then use inventory
    inventory/service/groups.yaml

Various other places are updated to use this abstracted group as the
bastion host.

Variables are moved into the bastion group (which only has one host --
the actual bastion host) which means we only have to update the group
mapping to the new host.

This is intended to be a no-op change; all the jobs should work the
same, but just using the new abstractions.

Change-Id: Iffb462371939989b03e5d6ac6c5df63aa7708513
2022-10-20 09:00:43 +11:00

83 lines
2.2 KiB
YAML

- hosts: localhost
tasks:
- name: Make log directories for testing hosts
file:
path: "{{ zuul.executor.log_root }}/{{ item }}/logs"
state: directory
recurse: true
loop: "{{ query('inventory_hostnames', 'all') }}"
- hosts: all
tasks:
- include_role:
name: collect-container-logs
# The zuul user isn't part of the docker group on our fake
# production systems. Work around this by operating as root
# when collecting logs. This collects podman containers
# running as root; we may need to think about some flags for
# this role for collecting logs from containers under other
# users.
apply:
become: yes
vars:
container_command: "{{ item }}"
loop:
- docker
- podman
- include_role:
name: stage-output
- hosts: bastion
tasks:
- name: Set log directory
set_fact:
log_dir: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}"
- name: Collect tox output
include_role:
name: fetch-tox-output
vars:
tox_envlist: testinfra
zuul_work_dir: src/opendev.org/opendev/system-config
# Because during the test we run ansible as root, we need
# to allow ourselves permissions to copy the results
- name: Open ARA results permissions
file:
dest: /var/cache/ansible
mode: u=rwX,g=rX,o=rX
recurse: yes
become: yes
- name: Generate ARA static report
command: /usr/ansible-venv/bin/ara-manage generate /root/.ara/static
become: yes
- name: Collect testing ARA results
synchronize:
dest: "{{ log_dir }}/ara-report"
mode: pull
src: "/root/.ara/static/"
verify_host: true
become: yes
ignore_errors: true
- name: Add ARA artifact
zuul_return:
data:
zuul:
artifacts:
- name: ARA report
url: '{{ groups["bastion"][0] }}/ara-report/'
- name: Collect ansible configuration
synchronize:
dest: "{{ log_dir }}/etc"
mode: pull
src: "/etc/ansible"
verify_host: true
rsync_opts:
- "--exclude=__pycache__"
ignore_errors: true