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

NAME

6       cdist-type__line - Manage lines in files
7

DESCRIPTION

9       This cdist type allows you to add lines and remove lines from files.
10

REQUIRED PARAMETERS

12       None.
13

OPTIONAL PARAMETERS

15       after  Insert the given line after this pattern.
16
17       before Insert the given line before this pattern.
18
19       file   If  supplied,  use  this as the destination file.  Otherwise the
20              object_id is used.
21
22       line   Specifies the line which should be absent or present.
23
24              Must be present, if state is 'present' or 'replace'.  Ignored if
25              regex is given and state is 'absent'.
26
27       regex  If state is 'present', search for this pattern and if it matches
28              add the given line.
29
30              If state is 'absent', ensure  all  lines  matching  the  regular
31              expression are absent.
32
33              If  state  is  'replace',  ensure all lines matching the regular
34              expression are exactly 'line'.
35
36              The regular expression is interpreted by awk's match function.
37
38       state  'present', 'absent' or 'replace', defaults to 'present'.
39
40       onchange
41              The code to run if line is added, removed or updated.
42

BOOLEAN PARAMETERS

44       None.
45

MESSAGES

47       added  The line was added.
48
49       updated
50              The line or its position was changed.
51
52       removed
53              The line was removed.
54

EXAMPLES

56          # Manage a hosts entry for www.example.com.
57          __line /etc/hosts \
58              --line '127.0.0.2 www.example.com'
59
60          # Manage another hosts entry for test.example.com.
61          __line hosts:test.example.com \
62              --file /etc/hosts \
63              --line '127.0.0.3 test.example.com'
64
65          # Remove the line starting with TIMEZONE from the /etc/rc.conf file.
66          __line legacy_timezone \
67             --file /etc/rc.conf \
68             --regex 'TIMEZONE=.*' \
69             --state absent
70
71          # Insert a line before another one.
72          __line password-auth-local:classify \
73              --file /etc/pam.d/password-auth-local \
74              --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \
75              --before '^session[[:space:]]+include[[:space:]]+password-auth-ac$'
76
77          # Insert a line after another one.
78          __line password-auth-local:classify \
79              --file /etc/pam.d/password-auth-local \
80              --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \
81              --after '^session[[:space:]]+include[[:space:]]+password-auth-ac$'
82
83          # Uncomment as needed and set a value in a configuration file.
84          __line /etc/example.conf \
85              --line 'SomeSetting SomeValue' \
86              --regex '^(#[[:space:]]*)?SomeSetting[[:space:]]' \
87              --state replace
88

SEE ALSO

90       cdist-type(7)
91

AUTHORS

93       Steven Armstrong <steven-cdist--@--armstrong.cc>
94

COPYING

96       Copyright (C) 2018 Steven Armstrong.  Free  use  of  this  software  is
97       granted  under  the  terms  of the GNU General Public License version 3
98       (GPLv3).
99
101       ungleich GmbH 2020
102
103
104
105
1066.9.4                            Dec 21, 2020              CDIST-TYPE__LINE(7)
Impressum