fileexists(path) returns true if a file exists at path, and false otherwise. The path is relative to the playbook’s working directory.
Signature
Example
Install dependencies only when a lock file is present, skipping the step entirely when it is not:package-lock.json does not exist, the install task is skipped. build still runs but with no prior install step.
Notes
fileexistsonly returnstruefor regular files. Passing a path to a directory or other non-regular file returns an error, notfalse.- The path is relative to the playbook’s working directory at evaluation time.
- Use
fileexistsinconditionto make a task conditional on the presence of a configuration file, lock file, or generated artifact.