From 0f46964ea961ee032a7cd0bcbd33825a86d6bea4 Mon Sep 17 00:00:00 2001 From: John Helmert III Date: Sat, 30 Nov 2024 11:35:38 -0800 Subject: [PATCH] roles/fstab: remove file when no filesystems are configured Else we'll just have an empty file. Signed-off-by: John Helmert III --- roles/fstab/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/fstab/tasks/main.yml b/roles/fstab/tasks/main.yml index db79e73..128ed50 100644 --- a/roles/fstab/tasks/main.yml +++ b/roles/fstab/tasks/main.yml @@ -1,8 +1,14 @@ --- - name: Deploy fstab + when: filesystems | length > 0 ansible.builtin.template: src: fstab.j2 dest: /etc/fstab owner: root group: root mode: "0644" +- name: Remove fstab + when: filesystems | length == 0 + ansible.builtin.file: + path: /etc/fstab + state: absent