ansible-role-nodepool/tests/collect-logs.yaml
Paul Belanger 4666971ac5 Switch to molecule for testing
Molecule is the defacto testing tool for ansible roles. Switch to it to
make it easier for users to test.

Change-Id: I881e895877c9702e62c4415d48b0f33f34f7487b
Depends-On: https://review.openstack.org/593369
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2018-08-19 11:32:19 -04:00

47 lines
1.5 KiB
YAML

- hosts: all
tasks:
- name: Ensure journald logs directory exists
file:
path: "{{ zuul_output_dir }}/logs/logs/var/log/journal"
state: directory
- name: Collect journald logs
shell: "sudo journalctl -u {{ item }}.service | tee {{ zuul_output_dir }}/logs/logs/var/log/journal/{{ item }}.service.log"
args:
creates: "{{ zuul_output_dir }}/logs/logs/var/log/journal/{{ item }}.service.log"
with_items:
- nodepool-builder
- nodepool-launcher
- name: Collect testinfra reports
synchronize:
dest: "{{ zuul_output_dir }}/logs"
src: "{{ item }}"
verify_host: true
delegate_to: "{{ inventory_hostname }}"
with_items:
- "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/junit.xml"
- name: Prepare nodepool log files
become: yes
synchronize:
dest: "{{ zuul_output_dir }}/logs/logs"
rsync_opts:
- "--relative"
- "--chown={{ ansible_user_id }}:{{ ansible_user_id }}"
src: "{{ item }}"
verify_host: true
delegate_to: "{{ inventory_hostname }}"
with_items:
- /etc/nodepool
- /var/log/nodepool
# TODO: Migrate to fetch-zuul-logs when
# https://review.openstack.org/#/c/583346/ is merged.
- name: Collect log output
synchronize:
dest: "{{ zuul.executor.log_root }}/"
mode: pull
src: "{{ zuul_output_dir }}/logs/"
verify_host: true