feat: Adds a copy if not exists task, so that setup doesn't overwrite files if they exist.
This commit is contained in:
19
tasks/copy_if_not_exists.yml
Normal file
19
tasks/copy_if_not_exists.yml
Normal 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
|
||||
Reference in New Issue
Block a user