DOKK / manpages / debian 10 / cdist / cdist-type__install_file.7.en

cdist-type__install_file - Manage files with install command.

This cdist type allows you to create files, remove files and set file attributes on the target.

If the file already exists on the target, then if it is a:

replace it with the source file if they are not equal
do nothing

replace it with the source file
replace it with the source file

In any case, make sure that the file attributes are as specified.


'present', 'absent' or 'exists', defaults to 'present' where:
the file is exactly the one from source
the file does not exist
the file from source but only if it doesn't already exist

Group to chgrp to.
Unix permissions, suitable for chmod.
User to chown to.
If supplied, copy this file from the host running cdist to the target. If not supplied, an empty file or directory will be created. If source is '-' (dash), take what was written to stdin as the file content.

Changed group membership
Changed owner
Changed mode
Empty file was created (no --source specified)
File exists, but state is absent, file will be removed by generated code.
File was uploaded

# Create  /etc/cdist-configured as an empty file
__install_file /etc/cdist-configured
# The same thing
__install_file /etc/cdist-configured --state present
# Use __file from another type
__install_file /etc/issue --source "$__type/files/archlinux" --state present
# Delete existing file
__install_file /etc/cdist-configured --state absent
# Supply some more settings
__install_file /etc/shadow --source "$__type/files/shadow" \

--owner root --group shadow --mode 0640 \
--state present # Provide a default file, but let the user change it __install_file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \
--state exists \
--owner frodo --mode 0600 # Take file content from stdin __install_file /tmp/whatever --owner root --group root --mode 644 --source - << DONE
Here goes the content for /tmp/whatever DONE

Nico Schottelius <>

Copyright (C) 2011-2013 Nico Schottelius. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

February 16, 2019 4.10.6