2023-04-03 17:50:18 +00:00
|
|
|
---
|
|
|
|
# task/cleanup file for update_motd
|
|
|
|
- name: "Ensure no other files are in motd"
|
|
|
|
block:
|
|
|
|
- name: "Collect files in motd dir"
|
|
|
|
ansible.builtin.find:
|
|
|
|
paths: "{{ update_motd_path }}/"
|
|
|
|
hidden: true
|
|
|
|
recurse: true
|
|
|
|
file_type: any
|
|
|
|
register: collected_files
|
|
|
|
|
|
|
|
- name: 'Collect dir in motd dir'
|
|
|
|
ansible.builtin.find:
|
|
|
|
paths: "{{ update_motd_path }}/"
|
|
|
|
hidden: true
|
|
|
|
recurse: true
|
|
|
|
file_type: directory
|
|
|
|
register: collected_directories
|
|
|
|
|
|
|
|
- name: "Remove all unwanted files and directories"
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
|
|
|
loop: "{{ collected_files.files + collected_directories.files }}"
|
2023-04-03 20:49:15 +00:00
|
|
|
when: (item.path|basename) != update_motd_filename
|
|
|
|
|
|
|
|
- name: "Remove /etc/motd file"
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "/etc/motd"
|
|
|
|
state: absent
|