Files
ansible-hpa-playbook/roles/create_if_not_exists/tasks/main.yml
2024-11-25 17:06:32 -05:00

18 lines
454 B
YAML

---
# Check if a file exists at the destination already, copy it if not.
- name: "Check if {{ destination | basename }} exists."
ansible.builtin.stat:
path: "{{ destination }}"
register: filestat
tags:
- always
- name: "Copy {{ source }} file to {{ destination }}."
ansible.builtin.copy:
src: "{{ source }}"
dest: "{{ destination }}"
mode: "{{ mode | default('0600') }}"
when: not filestat.stat.exists
tags:
- always