Actually set `use_default_on_error=True` for files facts.
@@ -14,6 +14,9 @@ class File(FactBase):
# Types must match FLAG_TO_TYPE in .util.files.py
type = 'file'
+ # If the file doesn't exist, return `None` instead of failing
+ use_default_on_error = True
+
_ls_commands = [
'ls -ld --time-style=long-iso {0} 2> /dev/null', # Ubuntu, CentOS
'ls -ld --full-time {0} 2> /dev/null', # Newer BusyBox
@@ -72,6 +75,8 @@ class FindInFile(FactBase):
lines if the file exists, and ``None`` if the file does not.
'''
+ use_default_on_error = True
+
def command(self, name, pattern):
name = escape_unix_path(name)
pattern = shlex_quote(pattern)
