---
- name: Ensure directory for output exist
  become: true
  file:
    path: "{{ log_output_dir }}"
    state: directory

- name: Export errors from q-svc journual
  become: yes
  shell:
    cmd: |
      journalctl -o short-precise --unit devstack@q-svc | \
        grep -E '(ERROR|CRITICAL)' | \
        gzip - > {{ log_output_dir }}/errors-q-svc.txt.gz

- name: Collect exported errors
  synchronize:
    dest: "{{ zuul.executor.log_root }}"
    mode: pull
    src: "{{ log_output_dir }}/errors-q-svc.txt.gz"
    verify_host: true
