can ansible force a path to be a link even when it is a directory with files? currently i am deleting the directory before making it a link and it is not idempotent.
on the first run it deletes the directory. but it is also deleting and re-creating the link in every run after that.
for example of what i am trying to do:
name: remove existing link or directory
file:
path: /var/lib/mysql
state: absent
name: link mysql to datastore
file:
src: /mnt/datastore/mysql
dest: /var/lib/mysql
state: link
force: true
can ansible force a path to be a link even when it is a directory with
files? currently i am deleting the directory before making it a link and it
is not idempotent.
You can't force it, you need to delete and create link as you do now.
on the first run it deletes the directory. but it is also deleting and
re-creating the link in every run after that.
Before you delete and create link use the stat module to check if the path is a directory and then do a delete and create the link.