update_motd/tasks/cleanup.yml
Bertrand Lanson 2ed6f6ce8b
All checks were successful
test / Linting (push) Successful in 20s
test / Molecule tests (default, debian11) (push) Successful in 56s
test / Molecule tests (default, debian12) (push) Successful in 1m8s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m0s
test / Molecule tests (with_custom_ascii, debian11) (push) Successful in 56s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m24s
test / Molecule tests (with_custom_ascii, debian12) (push) Successful in 1m8s
test / Molecule tests (with_custom_ascii, ubuntu2004) (push) Successful in 59s
test / Molecule tests (with_custom_ascii, ubuntu2204) (push) Successful in 1m7s
feat: remove become from role, fix #1
2023-12-03 18:26:11 +01:00

32 lines
883 B
YAML

---
# 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 }}"
when: (item.path|basename) != update_motd_filename
- name: "Remove /etc/motd file"
ansible.builtin.file:
path: "/etc/motd"
state: absent