Relative paths in Ansible

I want to create the following. A relative path in a certain directory. For example in /home/user there is a file called hi.txt, I want to symlink it to bye.txt. With the command line that would then be cd /home/user; ln -s hi.txt bye.txt to create a hi.txt → bye.txt link in /home/user.

But with the Ansible module I always get a full path instead of a relative path in the path working directory. While the docs state “Relative paths are relative to the file being created (path) which is how the Unix command ln -s SRC DEST treats relative paths.”

In the docs is an example:

  • name: Create two hard links ansible.builtin.file:
    src: ‘/tmp/{{ item.src }}’
    dest: ‘{{ item.dest }}’
    state: hard
    loop:
  • { src: x, dest: y }
  • { src: z, dest: k }

However, this creates the symlinks in the root of my home directory rather than in /tmp. And the paths are not relative, they contain the full paths, so not x → y in /tmp.