CDIST-TYPE__INSTALL_FILE(7)
β¨ cdist-type__install_file β¨
okay bestie, welcome to cdist-type__install_file from the cdist manual pages (section 7, iykyk) π this one is literally about managing files with the install command and it's giving main character energy fr fr
π NAME π
cdist-type__install_file β manage files with the install command π
πΈ DESCRIPTION πΈ
so this cdist type lets you create files, remove files, and set file attributes on the target. three jobs, one icon π
if the file already exists on the target, then here's the vibe check depending on what it is:
- regular file, and state is:
presentβ replace it with the source file if they are not equal πexistsβ do nothing, just chill π
- symlink β replace it with the source file
- directory β replace it with the source file
one exception bestie, and it's important: when state is pre-exists, an error is raised if the file would have been created otherwise (e.g. it is not present or not a regular file). no sneaky creation allowed π«
and in any case, make sure that the file attributes are as specified. periodt.
π¦ REQUIRED PARAMETERS π¦
None. literally zero. nothing required, we love a low-maintenance type π«Ά
π OPTIONAL PARAMETERS π
stateβ'present','absent','exists'or'pre-exists', defaults to'present'where:presentβ the file is exactly the one from source β¨absentβ the file does not exist πexistsβ the file from source but only if it doesn't already existpre-existsβ check that the file exists and is a regular file, but do not create or modify it π
groupβ Group tochgrpto.modeβ Unix permissions, suitable forchmod.ownerβ User tochownto.sourceβ If supplied, copy this file from the host running cdist to the target. If not supplied, an empty file or directory will be created. Ifsourceis'-'(dash), take what was written to stdin as the file content. πonchangeβ The code to run if file is modified.
π MESSAGES π
chgrp <group>β Changed group membershipchown <owner>β Changed ownerchmod <mode>β Changed modecreateβ Empty file was created (no--sourcespecified)removeβ File exists, but state is absent, file will be removed by generated code.uploadβ File was uploaded
β EXAMPLES β
okay this is the part where it gets fun, watch π
# 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
# Check that the file is present, show an error when it is not
__install_file /etc/somefile --state pre-exists
# 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
π AUTHORS π
Nico Schottelius <nico-cdist--@--schottelius.org>
π COPYING π
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.
πΈ COPYRIGHT πΈ
ungleich GmbH 2021
okay bestie that's the whole page, every flag, every message, every example, all of it, no skips π
and that's a wrap π this was cdist version 7.0.0, dated Jul 31, 2022, and honestly? iconic. go manage some files, you've got this π¦π
π¦ where this page comes from
- fedora 43: cdist 7.0.0-16.fc43 Β· GPL-3.0-only
- fedora 44: cdist 7.0.0-18.fc44 Β· GPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms