---
# This is an example playbook to execute Ansible tests.

- name: Verify
  hosts: all
  gather_facts: false
  vars:
    id_product:
      - 0e11
      - 9115
      - 9117
  tasks:
    - name: Registor PSU Status
      ansible.builtin.stat:
        path: /etc/udev/rules.d/76-hil-psu.rules
      register: psu

    - name: Verify UDEV file exists
      assert:
        that:
          - "psu.stat.exists"
          - "psu.stat.isreg"
          - "psu.stat.path == '/etc/udev/rules.d/76-hil-psu.rules'"
          - "psu.stat.mode == '0644'"

    - name: Verify UDEV rules are installed
      shell: cat /etc/udev/rules.d/76-hil-psu.rules|grep {{ item }}
      register: result
      changed_when: false
      failed_when: result.rc != 0
      loop: "{{ id_product }}"
