# Relative paths in Ansible

**URL:** <https://forum.ansible.com/t/relative-paths-in-ansible/35340>\
**Category:** Ansible Project\
**Created:** [June 13, 2021, 11:01am UTC](https://forum.ansible.com/t/relative-paths-in-ansible/35340 "2021-06-13T11:01:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![K\_de\_Jong](https://avatars.discourse-cdn.com/v4/letter/k/51bf81/32.png) [@K\_de\_Jong](https://forum.ansible.com/u/K_de_Jong)\
**Post date:** [June 13, 2021, 11:01am UTC](https://forum.ansible.com/t/relative-paths-in-ansible/35340/1 "2021-06-13T11:01:57Z")

</div>

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.
