files Facts¶
The files facts provide information about the filesystem and it's contents on the target host.
Facts need to be imported before use, eg
See also: operations/files.
files.Block¶
Returns a (possibly empty) list of the lines found between the markers.
If the path doesn't exist
returns None
If the path exists but the markers are not found
returns []
files.Directory¶
Returns information about a directory on the remote system:
If the path does not exist:
returns None
If the path exists but is not a directory:
returns False
files.File¶
Returns information about a file on the remote system:
If the path does not exist:
returns None
If the path exists but is not a file:
returns False
files.FileContents¶
Returns the contents of a file as a list of lines, or None if the file does not exist.
files.FindDirectories¶
host.get_fact(FindDirectories, path, size=None, min_size=None, max_size=None, maxdepth=None, fname=None, iname=None, regex=None, path_match=None, args=None, quote_path=True)
Returns a list of directories from a start path, recursively using find.
files.FindFiles¶
host.get_fact(FindFiles, path, size=None, min_size=None, max_size=None, maxdepth=None, fname=None, iname=None, regex=None, path_match=None, args=None, quote_path=True)
Returns a list of files from a start path, recursively using find.
files.FindInFile¶
Checks for the existence of text in a file using grep. Returns a list of matching
lines if the file exists, and None if the file does not.
files.FindLinks¶
host.get_fact(FindLinks, path, size=None, min_size=None, max_size=None, maxdepth=None, fname=None, iname=None, regex=None, path_match=None, args=None, quote_path=True)
Returns a list of links from a start path, recursively using find.
files.Flags¶
Returns a list of the file flags set for the specified file or directory.
files.Link¶
Returns information about a link on the remote system:
If the path does not exist:
returns None
If the path exists but is not a link:
returns False
files.Md5File¶
Returns an MD5 hash of a file, or None if the file does not exist.
files.Sha1File¶
Returns a SHA1 hash of a file. Works with both sha1sum and sha1. Returns
None if the file doest not exist.
files.Sha256File¶
Returns a SHA256 hash of a file, or None if the file does not exist.
files.Sha384File¶
Returns a SHA384 hash of a file, or None if the file does not exist.
files.Socket¶
Returns information about a socket on the remote system:
If the path does not exist:
returns None
If the path exists but is not a socket:
returns False