Hi,

I'm just starting out with Ansible, and I probably haven't yet read all the 
docs I should, but I'm trying, so bear with me.

I have a simple play:

 - name: test
   file:
      path: "/path/to/file"
      owner: username
      group: usergroup
      mode: 0644
      follow: yes

My problem is that while this is sometimes a file and sometimes a link to 
another file, it is also sometimes a broken symlink (literally to "None" in 
my case, how that happens is another problem), and my play stops short (in 
check mode!) saying that I need to specify "force" to create the 
destination.

I do not want to create the destination (especially since it's "None"); if 
the symlink is broken I would like to replace it with an empty file (or 
maybe a template), unless I'm in check mode when I should simply note that 
a correction should be made.

Googling ansible and broken symlink didn't help me, so I started out with 
the stat module, and conditionals on the values and success of stat, asking 
myself if stat.originalfile is the destination of the link, and if I should 
use that or do two stats on the file, one with follow and one without, and 
when I was on my fourth task I decided to ask you all whether there's a 
simpler way :)

HAND

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6482a3af-e518-46ba-a0a3-46f4f734e21c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to