1CDIST-TYPE__INSTALL_FILE(7)          cdist         CDIST-TYPE__INSTALL_FILE(7)
2
3
4

NAME

6       cdist-type__install_file - Manage files with install command.
7

DESCRIPTION

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

REQUIRED PARAMETERS

34       None.
35

OPTIONAL PARAMETERS

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.
52
53       mode   Unix permissions, suitable for chmod.
54
55       owner  User to chown to.
56
57       source If supplied, copy this file from the host running cdist  to  the
58              target.   If  not  supplied,  an empty file or directory will be
59              created.  If source is '-' (dash),  take  what  was  written  to
60              stdin as the file content.
61
62       onchange
63              The code to run if file is modified.
64

MESSAGES

66       chgrp <group>
67              Changed group membership
68
69       chown <owner>
70              Changed owner
71
72       chmod <mode>
73              Changed mode
74
75       create Empty file was created (no --source specified)
76
77       remove File exists, but state is absent, file will be removed by gener‐
78              ated code.
79
80       upload File was uploaded
81

EXAMPLES

83          # Create  /etc/cdist-configured as an empty file
84          __install_file /etc/cdist-configured
85          # The same thing
86          __install_file /etc/cdist-configured --state present
87          # Use __file from another type
88          __install_file /etc/issue --source "$__type/files/archlinux" --state present
89          # Delete existing file
90          __install_file /etc/cdist-configured --state absent
91          # Supply some more settings
92          __install_file /etc/shadow --source "$__type/files/shadow" \
93             --owner root --group shadow --mode 0640 \
94             --state present
95          # Provide a default file, but let the user change it
96          __install_file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \
97             --state exists \
98             --owner frodo --mode 0600
99          # Check that the file is present, show an error when it is not
100          __install_file /etc/somefile --state pre-exists
101          # Take file content from stdin
102          __install_file /tmp/whatever --owner root --group root --mode 644 --source - << DONE
103              Here goes the content for /tmp/whatever
104          DONE
105

AUTHORS

107       Nico Schottelius <nico-cdist--@--schottelius.org>
108

COPYING

110       Copyright (C) 2011-2013  Nico  Schottelius.  You  can  redistribute  it
111       and/or  modify  it under the terms of the GNU General Public License as
112       published by the Free Software Foundation,  either  version  3  of  the
113       License, or (at your option) any later version.
114
116       ungleich GmbH 2019
117
118
119
120
1216.3.0                            Dec 12, 2019      CDIST-TYPE__INSTALL_FILE(7)
Impressum