1CDIST-TYPE__FILE(7) cdist CDIST-TYPE__FILE(7)
2
3
4
6 cdist-type__file - Manage files.
7
9 This cdist type allows you to create files, remove files and set file
10 attributes on the target.
11
12 If the file already exists on the target, then if it is a:
13
14 regular file, and state is:
15
16 present
17 replace it with the source file if they are not equal
18
19 exists do nothing
20
21 symlink
22 replace it with the source file
23
24 directory
25 replace it with the source file
26
27 One exception is that when state is pre-exists, an error is raised if
28 the file would have been created otherwise (e.g. it is not present or
29 not a regular file).
30
31 In any case, make sure that the file attributes are as specified.
32
34 None.
35
37 state 'present', 'absent', 'exists' or 'pre-exists', defaults to
38 'present' where:
39
40 present
41 the file is exactly the one from source
42
43 absent the file does not exist
44
45 exists the file from source but only if it doesn't already exist
46
47 pre-exists
48 check that the file exists and is a regular file, but do
49 not create or modify it
50
51 group Group to chgrp to. Defaults to root.
52
53 mode Unix permissions, suitable for chmod. Defaults to a very secure
54 0600.
55
56 owner User to chown to. Defaults to root.
57
58 source If supplied, copy this file from the host running cdist to the
59 target. If not supplied, an empty file or directory will be
60 created. If source is '-' (dash), take what was written to
61 stdin as the file content.
62
63 onchange
64 The code to run if file is modified.
65
67 chgrp <group>
68 Changed group membership
69
70 chown <owner>
71 Changed owner
72
73 chmod <mode>
74 Changed mode
75
76 create Empty file was created (no --source specified)
77
78 remove File exists, but state is absent, file will be removed by gener‐
79 ated code.
80
81 upload File was uploaded
82
84 # Create /etc/cdist-configured as an empty file
85 __file /etc/cdist-configured
86 # The same thing
87 __file /etc/cdist-configured --state present
88 # Use __file from another type
89 __file /etc/issue --source "$__type/files/archlinux" --state present
90 # Delete existing file
91 __file /etc/cdist-configured --state absent
92 # Supply some more settings
93 __file /etc/shadow --source "$__type/files/shadow" \
94 --owner root --group shadow --mode 0640 \
95 --state present
96 # Provide a default file, but let the user change it
97 __file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \
98 --state exists \
99 --owner frodo --mode 0600
100 # Check that the file is present, show an error when it is not
101 __file /etc/somefile --state pre-exists
102 # Take file content from stdin
103 __file /tmp/whatever --owner root --group root --mode 644 --source - << DONE
104 Here goes the content for /tmp/whatever
105 DONE
106
108 Nico Schottelius <nico-cdist--@--schottelius.org>
109
111 Copyright (C) 2011-2013 Nico Schottelius. You can redistribute it
112 and/or modify it under the terms of the GNU General Public License as
113 published by the Free Software Foundation, either version 3 of the Li‐
114 cense, or (at your option) any later version.
115
117 ungleich GmbH 2021
118
119
120
121
1227.0.0 Jul 31, 2022 CDIST-TYPE__FILE(7)