recursively create symlinks with relative paths

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.

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

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.

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

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