Skip to content

exists

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version 2.5.

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 P(ansible.builtin.link#test) or P(ansible.builtin.link_exists#test) tests to check on the link.

Parameters

Parameter Defaults / Choices Comments
_input
path
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 Values

Key Data Type Description Returned
_value boolean Returns V(True) if the path corresponds to an existing filesystem object on the controller (after following symlinks), V(False) if otherwise.

Authors

  • Ansible Core