ansible.builtin.exists test – does the path exist, follow symlinks
Note
This test plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
exists
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.exists
for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same test plugin name.
Synopsis
Check if the provided path maps to an existing filesystem object on the controller (localhost).
Follows symlinks and checks the target of the symlink instead of the link itself, use the ansible.builtin.link or ansible.builtin.link_exists tests to check on the link.
Input
This describes the input of the test, the value before is ansible.builtin.exists
or is not ansible.builtin.exists
.
Parameter |
Comments |
---|---|
a path |
Examples
vars:
my_etc_hosts_exists: "{{ '/etc/hosts' is exists }}"
list_of_local_files_to_copy_to_remote: "{{ list_of_all_possible_files | select('exists') }}"
Return Value
Key |
Description |
---|---|
Returns Returned: success |