2021-12-03 11:32:31 +11:00
|
|
|
- import_playbook: ../bootstrap-bridge.yaml
|
2018-08-22 09:46:07 -07:00
|
|
|
vars:
|
2020-07-14 13:13:13 +10:00
|
|
|
root_rsa_key: "{{ lookup('file', zuul.executor.work_root + '/' + zuul.build + '_id_rsa', rstrip=False) }}"
|
2019-07-16 14:56:04 +10:00
|
|
|
ansible_cron_disable_job: true
|
|
|
|
cloud_launcher_disable_job: true
|
2018-08-22 09:46:07 -07:00
|
|
|
|
2022-07-04 15:36:31 +10:00
|
|
|
# setup opendev CA
|
|
|
|
- hosts: bridge.openstack.org
|
|
|
|
become: true
|
|
|
|
tasks:
|
|
|
|
- name: Make temporary dir for CA generation
|
|
|
|
tempfile:
|
|
|
|
state: directory
|
|
|
|
register: _ca_tempdir
|
|
|
|
|
|
|
|
- name: Create CA PEM/crt
|
|
|
|
shell: |
|
|
|
|
set -x
|
|
|
|
# Generate a CA key
|
|
|
|
openssl genrsa -out ca.key 2048
|
|
|
|
# Create fake CA root certificate
|
|
|
|
openssl req -x509 -new -nodes -key ca.key -sha256 -days 30 -subj "/C=US/ST=CA/O=OpenDev Infra" -out ca.crt
|
|
|
|
args:
|
|
|
|
chdir: '{{ _ca_tempdir.path }}'
|
|
|
|
executable: /bin/bash
|
|
|
|
|
|
|
|
- name: Save key
|
|
|
|
slurp:
|
|
|
|
src: '{{ _ca_tempdir.path }}/ca.key'
|
|
|
|
register: _opendev_ca_key
|
|
|
|
|
|
|
|
- name: Save certificate
|
|
|
|
slurp:
|
|
|
|
src: '{{ _ca_tempdir.path }}//ca.crt'
|
|
|
|
register: _opendev_ca_certificate
|
|
|
|
|
|
|
|
- name: Cleanup tempdir
|
|
|
|
file:
|
|
|
|
path: '{{ _ca_tempdir.path }}'
|
|
|
|
state: absent
|
|
|
|
when: _ca_tempdir.path is defined
|
|
|
|
|
|
|
|
- hosts: all
|
|
|
|
become: true
|
|
|
|
tasks:
|
|
|
|
- name: Make CA directory
|
|
|
|
file:
|
|
|
|
path: '/etc/opendev-ca'
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
|
|
|
|
|
|
|
- name: Import files
|
|
|
|
shell: 'echo "{{ item.content }}" | base64 -d > {{ item.file }}'
|
|
|
|
args:
|
|
|
|
creates: '{{ item.file }}'
|
|
|
|
loop:
|
|
|
|
- file: '/etc/opendev-ca/ca.key'
|
|
|
|
content: '{{ hostvars["bridge.openstack.org"]["_opendev_ca_key"]["content"] }}'
|
|
|
|
- file: '/etc/opendev-ca/ca.crt'
|
|
|
|
content: '{{ hostvars["bridge.openstack.org"]["_opendev_ca_certificate"]["content"] }}'
|
|
|
|
|
|
|
|
- name: Install and trust certificate
|
|
|
|
shell:
|
|
|
|
cmd: |
|
|
|
|
cp /etc/opendev-ca/ca.crt /usr/local/share/ca-certificates/opendev-infra-ca.crt
|
|
|
|
update-ca-certificates
|
|
|
|
|
2018-08-22 09:46:07 -07:00
|
|
|
- hosts: bridge.openstack.org
|
|
|
|
become: true
|
|
|
|
tasks:
|
|
|
|
- name: Write inventory on bridge
|
|
|
|
include_role:
|
|
|
|
name: write-inventory
|
|
|
|
vars:
|
2020-05-26 15:46:41 -05:00
|
|
|
write_inventory_dest: /home/zuul/src/opendev.org/opendev/system-config/inventory/base/gate-hosts.yaml
|
2018-08-22 09:46:07 -07:00
|
|
|
write_inventory_exclude_hostvars:
|
|
|
|
- ansible_user
|
2019-07-10 10:05:18 -07:00
|
|
|
- ansible_python_interpreter
|
2020-05-08 14:15:01 -07:00
|
|
|
write_inventory_additional_hostvars:
|
2020-06-03 14:20:36 -07:00
|
|
|
public_v4: nodepool.private_ipv4
|
2020-05-08 14:15:01 -07:00
|
|
|
public_v6: nodepool.public_ipv6
|
2018-09-12 11:32:42 -06:00
|
|
|
- name: Add groups config for test nodes
|
|
|
|
template:
|
|
|
|
src: "templates/gate-groups.yaml.j2"
|
|
|
|
dest: "/etc/ansible/hosts/gate-groups.yaml"
|
2018-08-29 11:04:07 -07:00
|
|
|
- name: Update ansible.cfg to use job inventory
|
|
|
|
ini_file:
|
|
|
|
path: /etc/ansible/ansible.cfg
|
|
|
|
section: defaults
|
|
|
|
option: inventory
|
2020-05-26 15:46:41 -05:00
|
|
|
value: /home/zuul/src/opendev.org/opendev/system-config/inventory/base/gate-hosts.yaml,/home/zuul/src/opendev.org/opendev/system-config/inventory/service/groups.yaml,/etc/ansible/hosts/gate-groups.yaml
|
2018-08-22 09:46:07 -07:00
|
|
|
- name: Make host_vars directory
|
|
|
|
file:
|
|
|
|
path: "/etc/ansible/hosts/host_vars"
|
|
|
|
state: directory
|
|
|
|
- name: Make group_vars directory
|
|
|
|
file:
|
|
|
|
path: "/etc/ansible/hosts/group_vars"
|
|
|
|
state: directory
|
|
|
|
- name: Write hostvars files
|
|
|
|
vars:
|
|
|
|
bastion_ipv4: "{{ nodepool['public_ipv4'] }}"
|
|
|
|
bastion_ipv6: "{{ nodepool['public_ipv6'] }}"
|
|
|
|
bastion_public_key: "{{ lookup('file', zuul.executor.work_root + '/' + zuul.build + '_id_rsa.pub') }}"
|
2020-12-15 15:22:26 +11:00
|
|
|
iptables_test_public_tcp_ports:
|
|
|
|
# Zuul web console
|
|
|
|
- 19885
|
|
|
|
# selenium
|
|
|
|
- 4444
|
2018-08-22 09:46:07 -07:00
|
|
|
template:
|
|
|
|
src: "templates/{{ item }}.j2"
|
|
|
|
dest: "/etc/ansible/hosts/{{ item }}"
|
|
|
|
loop:
|
|
|
|
- group_vars/all.yaml
|
2018-10-31 16:13:33 -07:00
|
|
|
- group_vars/adns.yaml
|
2020-04-19 12:34:06 -05:00
|
|
|
- group_vars/eavesdrop.yaml
|
2018-08-30 12:17:31 -07:00
|
|
|
- group_vars/nodepool.yaml
|
2018-11-01 13:24:41 -07:00
|
|
|
- group_vars/ns.yaml
|
2019-01-31 09:59:26 -08:00
|
|
|
- group_vars/registry.yaml
|
2019-02-15 15:18:15 -08:00
|
|
|
- group_vars/gitea.yaml
|
2019-02-19 14:41:54 -08:00
|
|
|
- group_vars/gitea-lb.yaml
|
2021-03-05 16:10:01 +11:00
|
|
|
- group_vars/kerberos-kdc.yaml
|
2021-11-30 13:03:12 -08:00
|
|
|
- group_vars/keycloak.yaml
|
2019-02-14 08:10:51 +11:00
|
|
|
- group_vars/letsencrypt.yaml
|
2020-04-20 09:05:51 -07:00
|
|
|
- group_vars/meetpad.yaml
|
2020-05-18 12:28:51 -07:00
|
|
|
- group_vars/jvb.yaml
|
2021-03-19 14:55:02 +11:00
|
|
|
- group_vars/refstack.yaml
|
2019-04-17 14:39:32 -07:00
|
|
|
- group_vars/registry.yaml
|
2019-02-28 12:10:49 +00:00
|
|
|
- group_vars/control-plane-clouds.yaml
|
2019-12-10 13:11:14 +11:00
|
|
|
- group_vars/afs-client.yaml
|
2022-02-10 09:28:46 -08:00
|
|
|
- group_vars/zuul-lb.yaml
|
2020-04-05 09:25:28 -05:00
|
|
|
- group_vars/zuul.yaml
|
2020-04-24 17:40:32 -05:00
|
|
|
- group_vars/zuul-executor.yaml
|
2020-04-05 09:25:28 -05:00
|
|
|
- group_vars/zuul-merger.yaml
|
|
|
|
- group_vars/zuul-scheduler.yaml
|
|
|
|
- group_vars/zuul-web.yaml
|
2018-08-30 12:17:31 -07:00
|
|
|
- host_vars/bridge.openstack.org.yaml
|
2020-11-17 17:13:46 +11:00
|
|
|
- host_vars/codesearch01.opendev.org.yaml
|
2020-03-31 16:33:26 -05:00
|
|
|
- host_vars/etherpad01.opendev.org.yaml
|
2019-02-14 08:10:51 +11:00
|
|
|
- host_vars/letsencrypt01.opendev.org.yaml
|
|
|
|
- host_vars/letsencrypt02.opendev.org.yaml
|
2020-04-29 08:24:50 -07:00
|
|
|
- host_vars/lists.openstack.org.yaml
|
2021-05-04 11:55:47 -07:00
|
|
|
- host_vars/lists.katacontainers.io.yaml
|
2019-11-13 16:33:35 -08:00
|
|
|
- host_vars/gitea99.opendev.org.yaml
|
2020-06-23 11:41:27 +10:00
|
|
|
- host_vars/grafana01.opendev.org.yaml
|
2019-06-17 11:15:38 +10:00
|
|
|
- host_vars/mirror01.openafs.provider.opendev.org.yaml
|
2020-05-12 08:53:25 +10:00
|
|
|
- host_vars/mirror02.openafs.provider.opendev.org.yaml
|
2019-06-27 14:20:02 +10:00
|
|
|
- host_vars/mirror-update01.opendev.org.yaml
|
2022-07-06 05:54:55 +10:00
|
|
|
- host_vars/paste99.opendev.org.yaml
|
2020-01-31 09:27:34 -08:00
|
|
|
- host_vars/refstack01.openstack.org.yaml
|
2021-10-12 09:26:44 -07:00
|
|
|
- host_vars/review99.opendev.org.yaml
|
2018-08-29 11:04:07 -07:00
|
|
|
- name: Display group membership
|
|
|
|
command: ansible localhost -m debug -a 'var=groups'
|
2018-08-22 09:46:07 -07:00
|
|
|
- name: Run base.yaml
|
2022-03-02 13:42:13 +11:00
|
|
|
shell: 'set -o pipefail && ansible-playbook -f 50 -v /home/zuul/src/opendev.org/opendev/system-config/playbooks/base.yaml 2>&1 | tee /var/log/ansible/base.yaml.log'
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2019-05-02 15:07:32 -06:00
|
|
|
- name: Run bridge service playbook
|
2022-03-02 13:42:13 +11:00
|
|
|
shell: 'set -o pipefail && ansible-playbook -v /home/zuul/src/opendev.org/opendev/system-config/playbooks/service-bridge.yaml 2>&1 | tee /var/log/ansible/service-bridge.yaml.log'
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2021-02-10 16:32:51 -08:00
|
|
|
- name: Run dstat logger playbook
|
2022-03-02 13:42:13 +11:00
|
|
|
shell: 'set -o pipefail && ansible-playbook -v /home/zuul/src/opendev.org/opendev/system-config/playbooks/service-dstatlogger.yaml 2>&1 | tee /var/log/ansible/service-dstatlogger.yaml.log'
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
Base work for exporting encrypted logs
Our production jobs currently only put their logging locally on the
bastion host. This means that to help maintain a production system,
you effectively need full access to the bastion host to debug any
misbehaviour.
We've long discussed publishing these Ansible runs as public logs, or
via a reporting system (ARA, etc.) but, despite our best efforts at
no_log and similar, we are not 100% sure that secret values may not
leak.
This is the infrastructure for an in-between solution, where we
publish the production run logs encrypted to specific GPG public keys.
Here we are capturing and encrypting the logs of the
system-config-run-* jobs, and providing a small download script to
automatically grab and unencrypt the log files. Obviously this is
just to exercise the encryption/log-download path for these jobs, as
the logs are public.
Once this has landed, I will propose similar for the production jobs
(because these are post-pipeline this takes a bit more fiddling and
doens't run in CI). The variables will be setup in such a way that if
someone wishes to help maintain a production system, they can add
their public-key and then add themselves to the particular
infra-prod-* job they wish to view the logs for.
It is planned that the extant operators will be in the default list;
however this is still useful over the status quo -- instead of having
to search through the log history on the bastion host when debugging a
failed run, they can simply view the logs from the failing build in
Zuul directly.
Depends-On: https://review.opendev.org/c/zuul/zuul-jobs/+/828818/
Change-Id: I5b9f9dd53eb896bb542652e8175c570877842584
2022-02-11 12:06:13 +11:00
|
|
|
|
2019-05-02 15:07:32 -06:00
|
|
|
- name: Run playbook
|
|
|
|
when: run_playbooks is defined
|
|
|
|
loop: "{{ run_playbooks }}"
|
2022-03-02 13:42:13 +11:00
|
|
|
shell: "set -o pipefail && ansible-playbook -f 50 -v /home/zuul/src/opendev.org/opendev/system-config/{{ item }} 2>&1 | tee /var/log/ansible/{{ item | basename }}.log"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
Base work for exporting encrypted logs
Our production jobs currently only put their logging locally on the
bastion host. This means that to help maintain a production system,
you effectively need full access to the bastion host to debug any
misbehaviour.
We've long discussed publishing these Ansible runs as public logs, or
via a reporting system (ARA, etc.) but, despite our best efforts at
no_log and similar, we are not 100% sure that secret values may not
leak.
This is the infrastructure for an in-between solution, where we
publish the production run logs encrypted to specific GPG public keys.
Here we are capturing and encrypting the logs of the
system-config-run-* jobs, and providing a small download script to
automatically grab and unencrypt the log files. Obviously this is
just to exercise the encryption/log-download path for these jobs, as
the logs are public.
Once this has landed, I will propose similar for the production jobs
(because these are post-pipeline this takes a bit more fiddling and
doens't run in CI). The variables will be setup in such a way that if
someone wishes to help maintain a production system, they can add
their public-key and then add themselves to the particular
infra-prod-* job they wish to view the logs for.
It is planned that the extant operators will be in the default list;
however this is still useful over the status quo -- instead of having
to search through the log history on the bastion host when debugging a
failed run, they can simply view the logs from the failing build in
Zuul directly.
Depends-On: https://review.opendev.org/c/zuul/zuul-jobs/+/828818/
Change-Id: I5b9f9dd53eb896bb542652e8175c570877842584
2022-02-11 12:06:13 +11:00
|
|
|
|
|
|
|
- name: Build list of playbook logs
|
|
|
|
find:
|
|
|
|
paths: '/var/log/ansible'
|
|
|
|
patterns: '*.yaml.log'
|
|
|
|
register: _run_playbooks_logs
|
|
|
|
|
|
|
|
- name: Encrypt playbook logs
|
|
|
|
when: run_playbooks is defined
|
|
|
|
include_role:
|
|
|
|
name: encrypt-logs
|
|
|
|
vars:
|
|
|
|
encrypt_logs_files: '{{ _run_playbooks_logs.files | map(attribute="path") | list }}'
|
|
|
|
encrypt_logs_artifact_path: 'bridge.openstack.org/ansible'
|
|
|
|
encrypt_logs_download_script_path: '/var/log/ansible'
|
|
|
|
|
2019-03-05 15:24:24 -08:00
|
|
|
- name: Run test playbook
|
2019-05-02 15:07:32 -06:00
|
|
|
when: run_test_playbook is defined
|
2022-03-02 13:42:13 +11:00
|
|
|
shell: "set -o pipefail && ANSIBLE_ROLES_PATH=/home/zuul/src/opendev.org/opendev/system-config/playbooks/roles ansible-playbook -v /home/zuul/src/opendev.org/opendev/system-config/{{ run_test_playbook }} 2>&1 | tee /var/log/ansible/{{ run_test_playbook | basename }}.log"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2020-05-20 09:06:40 +10:00
|
|
|
|
|
|
|
- name: Generate testinfra extra data fixture
|
|
|
|
set_fact:
|
|
|
|
testinfra_extra_data:
|
|
|
|
zuul_job: '{{ zuul.job }}'
|
|
|
|
zuul: '{{ zuul }}'
|
|
|
|
|
|
|
|
- name: Write out testinfra extra data fixture
|
|
|
|
copy:
|
2020-06-03 13:58:18 -07:00
|
|
|
content: '{{ testinfra_extra_data | to_nice_yaml(indent=2) }}'
|
2020-05-20 09:06:40 +10:00
|
|
|
dest: '/home/zuul/testinfra_extra_data_fixture.yaml'
|
|
|
|
|
2020-12-15 15:22:26 +11:00
|
|
|
- name: Make screenshots directory
|
|
|
|
file:
|
|
|
|
path: '/var/log/screenshots'
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Return screenshots artifact
|
|
|
|
zuul_return:
|
|
|
|
data:
|
|
|
|
zuul:
|
|
|
|
artifacts:
|
|
|
|
- name: Screenshots
|
|
|
|
url: "bridge.openstack.org/screenshots"
|
|
|
|
|
2022-04-13 12:15:33 +10:00
|
|
|
- name: Allow PBR's git calls to operate in system-config, despite not owning it
|
|
|
|
command: git config --global safe.directory /home/zuul/src/opendev.org/opendev/system-config
|
|
|
|
|
2020-07-13 14:27:58 +10:00
|
|
|
- name: Run and collect testinfra
|
|
|
|
block:
|
|
|
|
- name: Run testinfra to validate configuration
|
|
|
|
include_role:
|
|
|
|
name: tox
|
|
|
|
vars:
|
|
|
|
tox_envlist: testinfra
|
|
|
|
# This allows us to run from external projects (like testinfra
|
|
|
|
# itself)
|
|
|
|
tox_environment:
|
|
|
|
TESTINFRA_EXTRA_DATA: '/home/zuul/testinfra_extra_data_fixture.yaml'
|
|
|
|
zuul_work_dir: src/opendev.org/opendev/system-config
|
|
|
|
always:
|
|
|
|
- name: Return testinfra report artifact
|
|
|
|
zuul_return:
|
|
|
|
data:
|
|
|
|
zuul:
|
|
|
|
artifacts:
|
|
|
|
- name: testinfra results
|
|
|
|
url: "bridge.openstack.org/test-results.html"
|