teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame tests/tests-reboot.yml

e50853
---
e50853
- hosts: localhost
e50853
  vars:
e50853
  - artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}"
e50853
  tags:
e50853
  - classic
e50853
  tasks:
e50853
  # switch SELinux to permissive mode
e50853
  - name: Get default kernel
e50853
    command: "grubby --default-kernel"
e50853
    register: default_kernel
e50853
  - debug: msg="{{ default_kernel.stdout }}"
e50853
  - name: Set permissive mode
e50853
    command: "grubby --args=enforcing=0 --update-kernel {{ default_kernel.stdout }}"
e50853
e50853
  - name: reboot
e50853
    block:
e50853
      - name: restart host
e50853
        shell: sleep 2 && shutdown -r now "Ansible updates triggered"
e50853
        async: 1
e50853
        poll: 0
e50853
        ignore_errors: true
e50853
e50853
      - name: wait for host to come back
e50853
        wait_for_connection:
e50853
          delay: 10
e50853
          timeout: 300
e50853
e50853
      - name: Re-create /tmp/artifacts
e50853
        command: mkdir /tmp/artifacts
e50853
e50853
      - name: Gather SELinux denials since boot
e50853
        shell: |
e50853
            result=pass
e50853
            dmesg | grep -i -e type=1300 -e type=1400 > /tmp/avc.log && result=fail
e50853
            ausearch -m avc -m selinux_err -m user_avc -ts boot &>> /tmp/avc.log
e50853
            grep -q '<no matches>' /tmp/avc.log || result=fail
e50853
            echo -e "\nresults:\n- test: reboot and collect AVC\n  result: $result\n  logs:\n  - avc.log\n\n" > /tmp/results.yml
e50853
            ( [ $result = "pass" ] && echo PASS test-reboot || echo FAIL test-reboot ) > /tmp/test.log
e50853
e50853
    always:
e50853
      - name: Pull out the artifacts
e50853
        fetch:
e50853
          dest: "{{ artifacts }}/"
e50853
          src: "{{ item }}"
e50853
          flat: yes
e50853
        with_items:
e50853
          - /tmp/test.log
e50853
          - /tmp/avc.log
e50853
          - /tmp/results.yml