From 93e2b84df05fd50fc0dda86af6c96fc4be9449ae Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 2 Mar 2022 13:42:13 +1100 Subject: [PATCH] zuul run-base: make sure we catch failures when teeing to logs Change I5b9f9dd53eb896bb542652e8175c570877842584 introduced this tee to capture and encrypt the logs. However, we should make sure to fail if the ansible runs fail. Switch on pipefail, which will exit with an error if the earlier parts of the pipeline fail. Also make sure we run under bash. Change-Id: I2c4cb9aec3d4f8bb5bb93e2d2c20168dc64e78cb --- playbooks/zuul/run-base.yaml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/playbooks/zuul/run-base.yaml b/playbooks/zuul/run-base.yaml index d6d7c61a46..8e159e9187 100644 --- a/playbooks/zuul/run-base.yaml +++ b/playbooks/zuul/run-base.yaml @@ -92,16 +92,24 @@ - name: Display group membership command: ansible localhost -m debug -a 'var=groups' - name: Run base.yaml - shell: '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' + 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 - name: Run bridge service playbook - shell: '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' + 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 - name: Run dstat logger playbook - shell: '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' + 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 - name: Run playbook when: run_playbooks is defined loop: "{{ run_playbooks }}" - shell: "ansible-playbook -f 50 -v /home/zuul/src/opendev.org/opendev/system-config/{{ item }} 2>&1 | tee /var/log/ansible/{{ item | basename }}.log" + 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 - name: Build list of playbook logs find: @@ -120,7 +128,9 @@ - name: Run test playbook when: run_test_playbook is defined - shell: "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" + 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 - name: Generate testinfra extra data fixture set_fact: