title: How to create a relative symlink in Ansible?
body: <p>In my playbook, I need to create a symbolic link for a repo.</p>
  <p>With command (shell) it may work like this:</p>
  <pre class="lang-yaml prettyprint-override"><code>########## Create symbolic link 
  - name: Create symbolic link 
    shell : ln   -s  &quot;{{SOURCE_FOLDER}}&quot;  SYMLINK
    args :
      chdir : &quot;/opt/application/i99/&quot;
    when:
      - ansible_host in groups['ihm']
  </code></pre>
  <p><strong>-&gt;</strong>  like this my symbolic link is created directly inside <strong>i99</strong> repo /</p>
  <p><code>SYMLINK</code> <strong>-&gt;</strong> <code>SOURCE_FOLDER</code></p>
  <p>But while doing it with the Ansible file module, like this:</p>
  <pre class="lang-yaml prettyprint-override"><code>########## Create symbolic link 
  - name: Create symbolic link 
    file:
     src: &quot;/opt/application/i99/{{SOURCE_FOLDER}}/&quot;
     dest: &quot;/opt/application/i99/SYMLINK&quot;
     state: link
    when:
      - ansible_host in groups['ihm']
  </code></pre>
  <p>My output is this :</p>
  <p><code>SYMLINK</code> <strong>-&gt;</strong> <code>/opt/application/i99/SOURCE_FOLDER</code></p>
  <p>As I don't want that it points to the whole path, and I need to obtain the first format:</p>
  <p><strong>SYMLINK -&gt; SOURCE_FOLDER</strong></p>
  <p>How can I do it?</p>