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:
parent
211a9950f5
commit
b099b439b4
@ -15,31 +15,41 @@
|
|||||||
|
|
||||||
- hosts: bridge.openstack.org
|
- hosts: bridge.openstack.org
|
||||||
tasks:
|
tasks:
|
||||||
- name: Log a playbook start header
|
- name: Ensure run dir
|
||||||
become: yes
|
file:
|
||||||
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'
|
state: directory
|
||||||
|
path: /var/run/ansible
|
||||||
|
|
||||||
- name: Run specified playbook on bridge.o.o and redirect output
|
- name: Run the production playbook and capture logs
|
||||||
become: yes
|
block:
|
||||||
shell: 'ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }} >> /var/log/ansible/{{ playbook_name }}.log'
|
|
||||||
|
|
||||||
# Not using normal zuul job roles as bridge.openstack.org is not a
|
- name: Log a playbook start header
|
||||||
# test node with all the normal bits in place.
|
become: yes
|
||||||
- name: Collect log output
|
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'
|
||||||
synchronize:
|
|
||||||
dest: "{{ zuul.executor.log_root }}/{{ playbook_name }}.log"
|
|
||||||
mode: pull
|
|
||||||
src: "/var/log/ansible/{{ playbook_name }}.log"
|
|
||||||
verify_host: true
|
|
||||||
when: infra_prod_playbook_collect_log
|
|
||||||
|
|
||||||
- name: Return playbook log artifact to Zuul
|
- name: Run specified playbook on bridge.o.o and redirect output
|
||||||
when: infra_prod_playbook_collect_log
|
become: yes
|
||||||
zuul_return:
|
shell: 'ansible-playbook -v -f {{ ansible_forks }} /opt/system-config/playbooks/{{ playbook_name }} >> /var/log/ansible/{{ playbook_name }}.log'
|
||||||
data:
|
|
||||||
zuul:
|
always:
|
||||||
artifacts:
|
|
||||||
- name: "Playbook Log"
|
# Not using normal zuul job roles as bridge.openstack.org is not a
|
||||||
url: "{{ playbook_name }}.log"
|
# test node with all the normal bits in place.
|
||||||
metadata:
|
- name: Collect log output
|
||||||
type: text
|
synchronize:
|
||||||
|
dest: "{{ zuul.executor.log_root }}/{{ playbook_name }}.log"
|
||||||
|
mode: pull
|
||||||
|
src: "/var/log/ansible/{{ playbook_name }}.log"
|
||||||
|
verify_host: true
|
||||||
|
when: infra_prod_playbook_collect_log
|
||||||
|
|
||||||
|
- name: Return playbook log artifact to Zuul
|
||||||
|
when: infra_prod_playbook_collect_log
|
||||||
|
zuul_return:
|
||||||
|
data:
|
||||||
|
zuul:
|
||||||
|
artifacts:
|
||||||
|
- name: "Playbook Log"
|
||||||
|
url: "{{ playbook_name }}.log"
|
||||||
|
metadata:
|
||||||
|
type: text
|
||||||
|
Loading…
Reference in New Issue
Block a user