15bdc6b
---
15bdc6b
- hosts: localhost
15bdc6b
  vars:
15bdc6b
  - artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}"
15bdc6b
  tags:
15bdc6b
  - classic
15bdc6b
  tasks:
15bdc6b
  - name: reboot
15bdc6b
    block:
15bdc6b
      - name: restart managed host
15bdc6b
        shell: sleep 2 && shutdown -r now "Ansible updates triggered"
15bdc6b
        async: 1
15bdc6b
        poll: 0
15bdc6b
        ignore_errors: true
15bdc6b
15bdc6b
      - name: wait for managed host to come back
15bdc6b
        wait_for_connection:
15bdc6b
          delay: 10
15bdc6b
          timeout: 300
15bdc6b
15bdc6b
      - name: Test block
15bdc6b
        shell: |
15bdc6b
            ausearch -m avc -m selinux_err -m user_avc -ts boot > /tmp/avc.log 2> /tmp/avc.err.log || exit 1
15bdc6b
            grep -q '<no matches>' /tmp/avc.err.log && result=pass || result=fail
15bdc6b
            echo -e "results:\n- {result: $result, test: proc}" > /tmp/results.yml
15bdc6b
15bdc6b
    always:
15bdc6b
      - name: Pull out the artifacts
15bdc6b
        fetch:
15bdc6b
          dest: "{{ artifacts }}/"
15bdc6b
          src: "{{ item }}"
15bdc6b
          flat: yes
15bdc6b
        with_items:
15bdc6b
          - /tmp/avc.log
15bdc6b
          - /tmp/avc.err.log
15bdc6b
          - /tmp/results.yml