Ian Wienand 860b0f9773 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
2018-12-14 10:33:27 -08:00

104 lines
2.8 KiB
YAML

- hosts: localhost
tasks:
- 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 }}/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 }}/hosts/{{ inventory_hostname }}"
- name: Register junit.xml file
stat:
path: "{{ zuul.project.src_dir }}/junit.xml"
register: _junit
- name: Collect testinfra logs
synchronize:
dest: "{{ zuul.executor.log_root }}"
mode: pull
src: "{{ zuul.project.src_dir }}/junit.xml"
verify_host: true
when: _junit.stat.exists|bool
# Because during the test we run ansible as root, we need
# to allow ourselves permissions to copy the results
- name: Open ARA results permissions
file:
dest: /var/cache/ansible
mode: u=rwX,g=rX,o=rX
recurse: yes
become: yes
# Note called ansible.sqlite so the middleware on
# logs.o.o picks it up for display
- name: Collect testing ARA results
synchronize:
dest: "{{ log_dir }}/ara-report/ansible.sqlite"
mode: pull
src: "/var/cache/ansible/ara.sqlite"
verify_host: true
ignore_errors: true
- name: Collect ansible configuration
synchronize:
dest: "{{ log_dir }}/etc"
mode: pull
src: "/etc/ansible"
verify_host: true
rsync_opts:
- "--exclude=__pycache__"
ignore_errors: true