ansible.builtin.relpath filter – Make a path relative
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
relpath
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.relpath
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
Synopsis
Input
This describes the input of the filter, the value before | ansible.builtin.relpath
.
Parameter |
Comments |
---|---|
A path. |
Positional parameters
This describes positional parameters of the filter. These are the values positional1
, positional2
and so on in the following
example: input | ansible.builtin.relpath(positional1, positional2, ...)
Parameter |
Comments |
---|---|
The directory the path should be relative to. If not supplied the current working directory will be used. |
Examples
# foobar => ../test/me.txt
testing: "{{ '/tmp/test/me.txt' | relpath('/tmp/other/') }}"
otherrelpath: "{{ mypath | relpath(mydir) }}"
Return Value
Key |
Description |
---|---|
The relative path. Returned: success |