Fix clobbering of existing directories/links

This commit is contained in:
2018-08-17 20:23:20 +02:00
parent 2654e28869
commit 3a1b490045

View File

@@ -167,6 +167,23 @@
tags:
- dotfiles
- name: get state of empty directories
stat:
path: ~/{{ item }}
register: empty_dir_stat
with_items: "{{ empty_directories }}"
tags:
- dotfiles
- name: remove sysmlinks
file:
path: "{{ item.stat.path }}"
state: absent
when: item.stat.exists and item.stat.islnk
with_items: "{{ empty_dir_stat.results }}"
tags:
- dotfiles
- name: create empty directories for dotfiles
file:
state: directory
@@ -195,6 +212,32 @@
tags:
- dotfiles
- name: get state of template targets
stat:
path: ~/{{ item.to }}
register: template_stat
when: item.template|default(false)
with_items: "{{ dotfiles }}"
tags:
- dotfiles
- debug:
var: template_stat
tags:
- dotfiles
- name: remove invalid template target (directory or symlink)
file:
path: "{{ item.stat.path }}"
state: absent
when:
- not item.skipped is defined or not item.skipped
- item.stat.exists
- not item.stat.isreg
with_items: "{{ template_stat.results }}"
tags:
- dotfiles
- name: deploy dotfiles templates
template:
src: ~/.dotfiles/{{ item.from }}.j2