# symlinks vs directories

**URL:** <https://forum.ansible.com/t/symlinks-vs-directories/14241>\
**Category:** Ansible Project\
**Created:** [December 30, 2013, 11:47pm UTC](https://forum.ansible.com/t/symlinks-vs-directories/14241 "2013-12-30T23:47:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [December 30, 2013, 11:47pm UTC](https://forum.ansible.com/t/symlinks-vs-directories/14241/1 "2013-12-30T23:47:08Z")

</div>

I have a task that creates a directory. On one server, that directory already exists, but is a symlink. So ansible says the task failed when it runs. The message: “msg: refusing to convert between link and directory for None”. Is there a way to tell ansible that a symlink is ok for that task?

Or check if a directory or symlink exists before running the task?

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [December 31, 2013, 12:48am UTC](https://forum.ansible.com/t/symlinks-vs-directories/14241/2 "2013-12-31T00:48:45Z")

</div>

With some help from IRC, I ended up checking for the paths with the stat module. Sadly, the only way that worked was to make 2 tasks per path. Glad I only had a few to check…

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 31, 2013, 12:22pm UTC](https://forum.ansible.com/t/symlinks-vs-directories/14241/3 "2013-12-31T12:22:41Z")

</div>

force=yes is available for such things.

There have been some recent refinements depending on what version you are using, but you didn’t specify.

If force=yes doesn’t handle this for you in the latest 1.5 development branch please file a ticket, and also reference the message about “None” as that’s suboptimal.

Thanks.

---

<div class="post-metadata">

**Author:** ![David\_Reagan](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@David\_Reagan](https://forum.ansible.com/u/David_Reagan)\
**Post date:** [December 31, 2013, 3:07pm UTC](https://forum.ansible.com/t/symlinks-vs-directories/14241/4 "2013-12-31T15:07:15Z")

</div>

Would force=yes overwrite the symlink that already exists?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [December 31, 2013, 3:14pm UTC](https://forum.ansible.com/t/symlinks-vs-directories/14241/5 "2013-12-31T15:14:46Z")

</div>

I think in this case you want a ‘follow=true’ which if it found a symlink would follow to source and validate that?
