CDIST-TYPE__KEY_VALUE(7)

πŸ’– cdist-type__key_value β€” the manual, but make it slay πŸ’–

okay bestie, gather round, because this is the cdist-type__key_value page from the cdist manual and it's literally about ✨changing property values in files✨. That's the whole vibe. She's a cdist type, she edits values in a key-value based config file, and she does it flawlessly. No cap. πŸŽ€


🌸 NAME 🌸

cdist-type__key_value β€” change property values in files, fr fr πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This cdist type lets you change values in a key value based config file. That's it. That's the job. And she eats every single time. πŸ‘‘


πŸŽ€ REQUIRED PARAMETERS πŸŽ€

Like, you genuinely have to give her these. Non-negotiable. πŸ’…

  • file β€” the file to operate on. The one we're editing. Yes, that one.
  • delimiter β€” the delimiter that separates the key from the value.

✨ OPTIONAL PARAMETERS ✨

These are the little extras, the accessories to the outfit 🫢

  • state β€” present or absent, and it defaults to present. If it's present, she sets the key to the value. If it's absent, she removes the key from the file. Gone. Not invited. πŸ’€
  • key β€” the key to change. Defaults to object_id. (iykyk)
  • value β€” the value for the key. Optional if state=absent, but required otherwise. You can't have a value-less value situation, bestie.
  • comment β€” if you supply this, the value gets inserted before the line with the key, but only if the key or value must be changed. And listen β€” you need to make sure yourself that the line is prefixed with the correct comment sign. Like # or ; or wathever .. She is not your comment-sign babysitter. πŸ™ˆ
  • onchange β€” the code to run if the key or value changes (i.e. is inserted, removed or replaced). Run it, queen. πŸ”₯

🌈 BOOLEAN PARAMETERS 🌈

  • exact_delimiter β€” if you supply this, additional whitespaces between key, delimiter and value get treated as a wrong value. Strict mode activated, no extra spaces allowed, periodt. βœ‹

πŸ’œ MESSAGES πŸ’œ

She talks to you, obviously. Here's what she says and what it means:

  • remove β€” Removed existing key and value
  • insert β€” Added key and value
  • change β€” Changed value of existing key
  • create β€” A new line was inserted in a new file

🌟 EXAMPLES 🌟

okay here's where it gets cute, look at her go:

# Set the maximum system user id
__key_value SYS_UID_MAX --file /etc/login.defs --value 666 --delimiter ' '

# Same with fancy id
__key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \
   --delimiter ' '

# Enable packet forwarding
__key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \
   --delimiter ' = ' --comment '# my linux kernel should act as a router'

# Remove existing key/value
__key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '='

not me being obsessed with that comment line, "my linux kernel should act as a router" is main character energy fr 🌸


🧚 MORE INFORMATION 🧚

This type tries to handle as many values as possible, so it does not use regexes. Which means: you need to exactly specify the key and the delimiter. No fuzzy guessing, no vibes-based matching. And good news β€” the delimiter can be of any length. Slay. ✨


πŸ‘‘ AUTHORS πŸ‘‘

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


πŸ“œ COPYING πŸ“œ

Copyright (C) 2011 Steven Armstrong. 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.


ungleich GmbH 2021


and that's the whole page, bestie 🫢 this was cdist 7.0.0, dated Jul 31, 2022, and honestly? iconic. go forth and edit your key values. mwah. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from