feat: Adds a copy if not exists task, so that setup doesn't overwrite files if they exist.

This commit is contained in:
2024-11-24 18:08:34 -05:00
parent 65acc3c45d
commit 4d011d2f75
4 changed files with 77 additions and 69 deletions

View File

@@ -0,0 +1,19 @@
---
# NOTE: This is just an internal task that checks if a file exists
# before copying, to prevent changes from being overwritten.
#
- name: "Check if {{ destination | basename }} exists already."
ansible.builtin.stat:
path: "{{ destination }}"
register: filestat
tags:
- always
- name: "Copy {{ destination | basename }} file."
ansible.builtin.copy:
src: "{{ source }}"
dest: "{{ destination }}"
mode: "{{ mode | default('0600') }}"
when: not filestat.stat.exists
tags:
- always