ansible-role-statsd/tests/collect-logs.yaml

41 lines
1.1 KiB
YAML

- hosts: localhost
tasks:
- name: Ensure logs directory exists
file:
path: "{{ item }}"
state: directory
with_items:
- "{{ zuul.executor.log_root }}/logs"
- "{{ zuul.executor.log_root }}/logs/var/log"
- hosts: all
tasks:
- name: Ensure journald logs directory exists
file:
path: "~/logs/journal"
state: directory
- name: Collect journald logs
become: yes
shell: "journalctl -u {{ item }}.service > /home/{{ ansible_user }}/logs/journal/{{ item }}.service.log"
args:
creates: "/home/{{ ansible_user }}/logs/journal/{{ item }}.service.log"
with_items:
- statsd
- name: Collect journald log files
synchronize:
dest: "{{ zuul.executor.log_root }}/logs/var/log"
mode: pull
src: "~/logs/journal"
verify_host: true
- name: Collect statsd log files
synchronize:
dest: "{{ zuul.executor.log_root }}/logs"
mode: pull
rsync_opts:
- "--relative"
src: /var/log/statsd
verify_host: true