Grab logs in the case of errors

More importantly, put the log collection in an always
section of block, otherwise we won't get logs if a
playbook fails, which is pretty much exactly when we
want to get logs.

Change-Id: Ia8e581e522f75a5f5945bc2143eec63b93381a94
This commit is contained in:
Monty Taylor 2020-04-01 20:03:07 -05:00
parent 211a9950f5
commit b099b439b4

View File

@ -15,6 +15,14 @@
- hosts: bridge.openstack.org - hosts: bridge.openstack.org
tasks: tasks:
- name: Ensure run dir
file:
state: directory
path: /var/run/ansible
- name: Run the production playbook and capture logs
block:
- name: Log a playbook start header - name: Log a playbook start header
become: yes become: yes
shell: 'echo "Running {{ ansible_date_time.iso8601 }}: ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }}" > /var/log/ansible/{{ playbook_name }}.log' shell: 'echo "Running {{ ansible_date_time.iso8601 }}: ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }}" > /var/log/ansible/{{ playbook_name }}.log'
@ -23,6 +31,8 @@
become: yes become: yes
shell: 'ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }} >> /var/log/ansible/{{ playbook_name }}.log' shell: 'ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }} >> /var/log/ansible/{{ playbook_name }}.log'
always:
# Not using normal zuul job roles as bridge.openstack.org is not a # Not using normal zuul job roles as bridge.openstack.org is not a
# test node with all the normal bits in place. # test node with all the normal bits in place.
- name: Collect log output - name: Collect log output