# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = low




- name: "Ensure the audispd's remote logging daemon executable is correct"
  block:
    - name: "Check for duplicate values"
      ansible.builtin.lineinfile:
        path: '/etc/audit/plugins.d/au-remote.conf'
        create: True
        regexp: '(?i)^\s*path\s*=\s*'
        state: 'absent'
      check_mode: yes
      changed_when: no
      register: 'dupes'
    - name: "Deduplicate values from /etc/audit/plugins.d/au-remote.conf"
      ansible.builtin.lineinfile:
        path: '/etc/audit/plugins.d/au-remote.conf'
        create: True
        regexp: '(?i)^\s*path\s*=\s*'
        state: 'absent'
      when: 'dupes.found is defined and dupes.found > 1'
    - name: "Insert correct line to /etc/audit/plugins.d/au-remote.conf"
      ansible.builtin.lineinfile:
        path: '/etc/audit/plugins.d/au-remote.conf'
        create: True
        regexp: '(?i)^\s*path\s*=\s*'
        line: 'path = /sbin/audisp-remote'
        state: present
