diff --git a/tasks/motd.yaml b/tasks/motd.yaml index 0d14723..304863f 100644 --- a/tasks/motd.yaml +++ b/tasks/motd.yaml @@ -4,25 +4,27 @@ tags: "motd" block: - # find old motd files - - name: "motd - find old scripts" - ansible.builtin.find: - paths: "/etc/update-motd.d/" - file_type: "file" - excludes: - - "10-custom-motd" - register: "old_motd" + # cleanup old motd debian + - name: "cleanup old motd debian" when: "ansible_os_family == 'Debian'" + block: - # remove old custom motd files - - name: "motd - cleanup directory" - ansible.builtin.file: - path: "{{ item.path }}" - state: "absent" - loop: "{{ old_motd.files }}" - when: - - "old_motd.files|length > 0" - - "ansible_os_family == 'Debian'" + # find old motd files + - name: "motd - find old scripts" + ansible.builtin.find: + paths: "/etc/update-motd.d/" + file_type: "file" + excludes: + - "10-custom-motd" + register: "old_motd" + + # remove old custom motd files + - name: "motd - cleanup directory" + ansible.builtin.file: + path: "{{ item.path }}" + state: "absent" + loop: "{{ old_motd.files }}" + when: "old_motd.files|length > 0" # remove old motd files - name: "motd - cleanup main file"