How to create a relative symlink in Ansible?

Question:

In my playbook, I need to create a symbolic link for a repo.

With command (shell) it may work like this:

-> like this my symbolic link is created directly inside i99 repo /

SYMLINK -> SOURCE_FOLDER

But while doing it with the Ansible file module, like this:

My output is this :

SYMLINK -> /opt/application/i99/SOURCE_FOLDER

As I don’t want that it points to the whole path, and I need to obtain the first format:

SYMLINK -> SOURCE_FOLDER

How can I do it?

Answer:

Simply:

As you can see in the manual for the file module:

src  Will accept absolute, relative and nonexisting paths. Relative paths are not expanded.

Leave a Reply