- hosts: pfservers, service_venom, nodes
  name: Get Venom logs on all VM
  become: True
  gather_facts: False
  tags: logs

  vars:
    # result_dir = full path to 'results' directory at root of PF sources tree
    result_dir: '{{ lookup("env", "RESULT_DIR") }}'

  pre_tasks:
  - name: Gather min and network only
    ansible.builtin.setup:
      gather_subset:
        - "!all"
        - "network"

  tasks:
    - name: Sanitize logs
      shell: '{{ venom_dir }}/utils/sanitize-venom-logs.sh'
      args:
        executable: '/bin/bash'
      no_log: True
      # to make Psono variables available
      environment: '{{ inventory__group_environment | d({}) }}'

    # Store archive into result_dir/results/results-$(hostname).tar.gz
    - name: Get logs on runner
      fetch:
        src: '{{ venom_dir }}/results-{{ ansible_fqdn }}.tar.gz'
        dest: '{{ result_dir }}/'
        flat: True
      failed_when: false
