CDIST-TYPE__LINE(7)
π cdist-type__line(7) β the one where we manage lines in files π
okay bestie, so this is a page from the cdist manual β it's section 7, and it's all about cdist-type__line, a cdist type that lets you add lines and remove lines from files. that's literally it, and it's iconic for it. β¨
πΈ NAME πΈ
cdist-type__line β manage lines in files π¦
π DESCRIPTION π
bestie. this cdist type lets you add lines and remove lines from files. that's the whole vibe. no cap, it just does lines. π₯
β¨ REQUIRED PARAMETERS β¨
None. zero. nada. you don't have to give it anything upfront, she's low maintenance. π«Ά
π OPTIONAL PARAMETERS π
afterβ insert the given line after this pattern. iykyk. πbeforeβ insert the given line before this pattern. the prequel energy. π§fileβ if you supply this, she uses it as the destination file. otherwise theobject_idis used. so like, pick one, she's not gonna guess for you. πΈlineβ specifies the line which should be absent or present. this is the main character, fr fr.
must be present ifstateis'present'or'replace'. and it gets ignored ifregexis given andstateis'absent'. so don't bother setting it there, she's not looking. π
regexβ the pattern girlie. here's the tea:- if
stateis'present', she searches for this pattern and if it matches, she adds the given line. β¨ - if
stateis'absent', she makes sure all lines matching the regular expression are absent. gone. not me deleting them. π - if
stateis'replace', she makes sure all lines matching the regular expression are exactly'line'. periodt.
- if
the regular expression is interpreted by awk's match function. so write it awk-style, bestie. π₯
stateβ'present','absent'or'replace'. defaults to'present'because optimism. πonchangeβ the code to run if the line is added, removed or updated. your little callback bestie. π
π¦ BOOLEAN PARAMETERS π¦
None. again, nothing. she's simple like that. π
β MESSAGES β
addedβ the line was added. new line just dropped. πupdatedβ the line or its position was changed. glow up. β¨removedβ the line was removed. she ate and left no crumbs. π
π EXAMPLES π
manage a hosts entry for www.example.com β classic.
# Manage a hosts entry for www.example.com.
__line /etc/hosts \
--line '127.0.0.2 www.example.com'
and another hosts entry for test.example.com, this time with an explicit --file and an object_id that's giving hosts:test.example.com:
# Manage another hosts entry for test.example.com.
__line hosts:test.example.com \
--file /etc/hosts \
--line '127.0.0.3 test.example.com'
removing a line? we love a deletion arc. remove the line starting with TIMEZONE from the /etc/rc.conf file:
# Remove the line starting with TIMEZONE from the /etc/rc.conf file.
__line legacy_timezone \
--file /etc/rc.conf \
--regex 'TIMEZONE=.*' \
--state absent
insert a line before another one β prequel era:
# Insert a line before another one.
__line password-auth-local:classify \
--file /etc/pam.d/password-auth-local \
--line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \
--before '^session[[:space:]]+include[[:space:]]+password-auth-ac$'
insert a line after another one β sequel era:
# Insert a line after another one.
__line password-auth-local:classify \
--file /etc/pam.d/password-auth-local \
--line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \
--after '^session[[:space:]]+include[[:space:]]+password-auth-ac$'
uncomment as needed and set a value in a configuration file β the replace state doing her thing:
# Uncomment as needed and set a value in a configuration file.
__line /etc/example.conf \
--line 'SomeSetting SomeValue' \
--regex '^(#[[:space:]]*)?SomeSetting[[:space:]]' \
--state replace
π«Ά SEE ALSO π«Ά
cdist-type(7)β go read that one next bestie, it's the lore. π
π AUTHORS π
Steven Armstrong <steven-cdist--@--armstrong.cc> β the icon, the moment, the legend. π
π COPYING π
Copyright (C) 2018 Steven Armstrong. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3).
π COPYRIGHT π
ungleich GmbH 2021
okay that's the whole page bestie, you're so welcome π β¨
and that's a wrap! this was cdist-type__line(7) from the cdist manual, version 7.0.0, dated Jul 31, 2022. go forth and manage your lines, you absolute main character. πππ¦πΈπ§π₯ππβπ
π¦ 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