update_motd/tasks/cleanup.yml
Bertrand Lanson 675f4650c9
All checks were successful
test / Linting (push) Successful in 7s
test / Molecule tests (default, debian11) (push) Successful in 1m2s
test / Molecule tests (default, debian12) (push) Successful in 58s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m6s
test / Molecule tests (with_custom_ascii, debian11) (push) Successful in 50s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m7s
test / Molecule tests (with_custom_ascii, debian12) (push) Successful in 1m11s
test / Molecule tests (with_custom_ascii, ubuntu2004) (push) Successful in 1m0s
test / Molecule tests (with_custom_ascii, ubuntu2204) (push) Successful in 1m9s
feat: add vagrant tests for later, add become:true
2023-11-30 22:24:37 +01:00

34 lines
917 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
become: true
- name: "Remove /etc/motd file"
ansible.builtin.file:
path: "/etc/motd"
state: absent
become: true