fs — the filesystem

The fs check examines the local filesystem and asserts that files or directories have certain properties. This includes its metadata, such as its owner or permissions; its contents, such as whether it contains a certain string; and its filesystem properties, such as where it links to if it’s a link.

Examples

Testing that a file exists:

[[fs]]
path = '/etc/nginx/nginx.conf'
kind = 'file'

Testing that a file contains the right content:

[[fs]]
path = '/etc/ssh/sshd_config'
kind = 'file'
contents = { regex = '^PermitRootLogin no' }

Testing that a file does not exist:

[[fs]]
path = '/home/balrog'
kind = 'absent'

Testing that a file is a symlink, and that it links to a certain path:

[[fs]]
path = '~/.psqlrc'
link_target = '~/Configs/psqlrc.sql'

Testing that a file the right permissions:

[[fs]]
path = '/usr/local/bin/script.sh'
permissions = 'u+x'

Testing that a file has the right owner or group:

[[fs]]
path = '/var/log/syslog'
owner = 'syslog'
group = 'adm'

Testing multiple things at once:

[[fs]]
path = '/etc/dh/dhparam_2048.pem'
kind = 'file'
owner = 'root'
group = 'root'
contents = { regex = [ '-----BEGIN DH PARAMETERS-----', '-----END DH PARAMETERS-----' ] }

List of parameters

parameterstructuredescription
contentscontentThe content that the file should have.
followbooleanWhether to follow symlinks (default: false).
groupnumber, or stringGroup ID or group name of the group of the file.
kindstringThe kind of file that exists at this path. This can be 'file' or 'directory' or 'symlink'.
link_targetstringThe target of this file as a symlink.
ownernumber, or stringUser ID or user name of the owner of the file.
pathstringThe path to the local file on disk that is being checked.
permissionsstringThe permissions of the file. (Alias: mode)
statestringThe state of the file at this path. This can be 'present' or 'missing'.