From 860b0f977389fed174d9e0a4e1b17dc30ea687ab Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 13 Dec 2018 09:53:47 +1100 Subject: [PATCH] Collect syslogs from nodes in ansible tests This collects syslogs from nodes running in our ansible gate tests. The node's logs are grouped under a "hosts" directory (the bridge.o.o logs are moved there for consistentcy too). Change-Id: I3869946888f09e189c61be4afb280673aa3a3f2e --- playbooks/zuul/run-base-post.yaml | 54 ++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/playbooks/zuul/run-base-post.yaml b/playbooks/zuul/run-base-post.yaml index a8813d4f5c..51527a2551 100644 --- a/playbooks/zuul/run-base-post.yaml +++ b/playbooks/zuul/run-base-post.yaml @@ -1,18 +1,64 @@ - hosts: localhost tasks: - - name: Ensure log directories exist + - name: Make log directories for testing hosts + file: + path: "{{ zuul.executor.log_root }}/hosts/{{ item }}/logs" + state: directory + recurse: true + loop: "{{ query('inventory_hostnames', 'all') }}" + + - name: Ensure bridge ARA log directories exist file: path: "{{ item }}" state: directory with_items: - - "{{ zuul.executor.log_root }}/bridge.o.o" - - "{{ zuul.executor.log_root }}/bridge.o.o/ara-report" + - "{{ zuul.executor.log_root }}/hosts/bridge.openstack.org/ara-report" + +- hosts: all + tasks: + - name: Set log directory + set_fact: + log_dir: "{{ zuul.executor.log_root }}/hosts/{{ inventory_hostname }}/logs" + + - name: Create list of files to collect + set_fact: + _to_collect: [] + + - name: Check for /var/log/syslog (debuntu) + stat: + path: '/var/log/syslog' + register: _syslog + become: yes + + - name: Collect syslog + set_fact: + _to_collect: '{{ _to_collect + [_syslog.stat.path] }}' + when: _syslog.stat.exists + + - name: Check for /var/log/messages (rpmish) + stat: + path: '/var/log/messages' + register: _messages + become: yes + + - name: Collect messages + set_fact: + _to_collect: '{{ _to_collect + [_messages.stat.path] }}' + when: _messages.stat.exists + + - name: 'Collect logs for {{ inventory_hostname }}' + synchronize: + dest: "{{ log_dir }}/{{ item | basename }}" + mode: pull + src: "{{ item }}" + become: yes + loop: "{{ _to_collect }}" - hosts: bridge.openstack.org tasks: - name: Set log directory set_fact: - log_dir: "{{ zuul.executor.log_root }}/bridge.o.o" + log_dir: "{{ zuul.executor.log_root }}/hosts/{{ inventory_hostname }}" - name: Register junit.xml file stat: