# recursively create symlinks with relative paths

**URL:** <https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861>\
**Category:** Ansible Project\
**Created:** [August 5, 2014, 5:05pm UTC](https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861 "2014-08-05T17:05:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [August 5, 2014, 5:05pm UTC](https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861/1 "2014-08-05T17:05:03Z")

</div>

Hello guys,

I am trying to get my head around parsing a folder for its files and creating symlinks for those files found (depth 0) and place them in another directory.

Example: parse sites-available/ and create symlinks in sites-enabled/ with relative paths.

I know one can just use the command/shell modules or even create a task and register the result of a ‘ls’ command for example and then parse them… but what about the relative path?  
One could also use a script like Apache provides for example: a2ensite but what about NGINX?

Trying now the ‘with\_fileglob’ but the task just skips…

Cheers.

---

<div class="post-metadata">

**Author:** ![adam2](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@adam2](https://forum.ansible.com/u/adam2)\
**Post date:** [August 5, 2014, 5:06pm UTC](https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861/2 "2014-08-05T17:06:59Z")

</div>

On debian, I could install the program 'symlinks'. I don't know if it is available elsewhere. It might be able to help.

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [August 5, 2014, 5:22pm UTC](https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861/3 "2014-08-05T17:22:44Z")

</div>

Hello,

I also know some non-ansible ways of doing this, but I am interested to see if it can be done entirely in Ansible.

Thanks.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 7, 2014, 9:15pm UTC](https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861/4 "2014-08-07T21:15:18Z")

</div>

I would have a list of what sites to enable and what sites to disable centrally, and do this with a simple with\_items instead, because it would be better to have a central record than to have potentially hundreds of different servers each being their own sources of record.

- template: src={{ site }}.cfg dest=/path/to/sites-available  
with\_items: enable\_sites

- file: src=… dest=…  
with\_items: enable\_sites

- file: src=… state=absent  
with\_items: disable\_sites

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [November 26, 2014, 10:16am UTC](https://forum.ansible.com/t/recursively-create-symlinks-with-relative-paths/15861/5 "2014-11-26T10:16:13Z")

</div>

Thanks Michael and sorry for the late response. This was indeed the path I ended up choosing.
