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
parameter | structure | description |
---|---|---|
contents | content | The content that the file should have. |
follow | boolean | Whether to follow symlinks (default: false ). |
group | number, or string | Group ID or group name of the group of the file. |
kind | string | The kind of file that exists at this path. This can be 'file' or 'directory' or 'symlink' . |
link_target | string | The target of this file as a symlink. |
owner | number, or string | User ID or user name of the owner of the file. |
path | string | The path to the local file on disk that is being checked. |
permissions | string | The permissions of the file. (Alias: mode ) |
state | string | The state of the file at this path. This can be 'present' or 'missing' . |