this is stupid

This commit is contained in:
2026-09-15 14:34:47 +05:30
parent 396e18ff18
commit abe2daebb9
+26 -2
View File
@@ -1,5 +1,29 @@
- name: check if parent dir exists
debug:
msg: "{{ path }}"
register: stat_output
ansible.builtin.stat:
path: "{{ path | dirname }}"
- name: create dir if not exists
when: not stat_output.stat.exists
ansible.builtin.file:
path: "{{ path | dirname }}"
state: directory
- name: backup and create dir if not dir
when: stat_output.stat.exists and not stat_output.stat.isdir
block:
- name: "backup existing {{ path | dirname }}"
no_log: true
ansible.builtin.copy:
src: "{{ path | dirname }}"
dest: "{{ path | dirname }}.old"
- name: "delete existing {{ path | dirname }}"
no_log: true
ansible.builtin.file:
path: "{{ path | dirname }}"
state: absent
- name: "create {{ path | dirname }}"
no_log: true
ansible.builtin.file:
path: "{{ path | dirname }}"
state: directory