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
This commit is contained in:
Ian Wienand 2018-12-13 09:53:47 +11:00 committed by Clark Boylan
parent 94eb7e5d2b
commit 860b0f9773

View File

@ -1,18 +1,64 @@
- hosts: localhost - hosts: localhost
tasks: 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: file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
with_items: with_items:
- "{{ zuul.executor.log_root }}/bridge.o.o" - "{{ zuul.executor.log_root }}/hosts/bridge.openstack.org/ara-report"
- "{{ zuul.executor.log_root }}/bridge.o.o/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 - hosts: bridge.openstack.org
tasks: tasks:
- name: Set log directory - name: Set log directory
set_fact: 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 - name: Register junit.xml file
stat: stat: