diff --git a/roles/splunk/tasks/configure_facl.yml b/roles/splunk/tasks/configure_facl.yml index 00d4772..7455812 100644 --- a/roles/splunk/tasks/configure_facl.yml +++ b/roles/splunk/tasks/configure_facl.yml @@ -20,12 +20,23 @@ - true - false + - name: Check if logrotate_file exists + ansible.builtin.stat: + path: "{{ logrotate_file }}" + register: logrotate_stat + become: true + + - name: Set use_logrotate fact based on file existence + ansible.builtin.set_fact: + use_logrotate: "{{ logrotate_stat.stat.exists | default(false) }}" + - name: Add setfacl to logrotate script ansible.builtin.lineinfile: path: "{{ logrotate_file }}" insertbefore: 'endscript' line: ' /usr/bin/setfacl -Rm u:{{ splunk_nix_user }}:rx /var/log' become: true + when: use_logrotate - name: Check if auditd.conf is present ansible.builtin.stat: