Files
ansible-hpa-playbook/roles/setup-project/tasks/copy_if_not_exists.yml
2024-11-26 14:26:58 -05:00

20 lines
524 B
YAML

---
# 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