IONIT(1)

πŸ“¦
version 0.5.1 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ¦‹ IONIT β€” the manual, but make it make sense

okay bestie, so this is the ionit man page, and honestly? she's a whole vibe. tiny tool, big main character energy. let's get into it ✨


✨ NAME ✨

ionit β€” render configuration files from Jinja templates πŸ’…


✨ SYNOPSIS ✨

ionit [OPTIONS]

that's it. that's the whole thing. no positional args, no drama. πŸŽ€


✨ DESCRIPTION ✨

ionit is a simple and small configuration templating tool. no cap, that's literally the description. she collects a context and renders Jinja templates in a given directory. and the context? it can be either static JSON or YAML files, or dynamic Python files. and the Python files can also define functions that get passed through to the rendering. iconic behavior fr fr πŸ’–

now here's the rules for the context filenames, bestie, write these down:

  • it needs to end with .json for JSON
  • .py for Python
  • .yaml for YAML

the context files are read in alphabetical order. so if the same key is defined by multiple context files, the file that is read later takes precedence (last one wins, periodt). so yeah β€” it is recommended to prefix the files with a number in case the order is relevant. like 10-networking.json, 20-users.yaml, you get it. 🧚

ionit comes with an early boot one shot service that is executed before the networking service, which lets you generate configuration files for the networking and other services before they are even started. so in that regard, ionit can act as a tiny stepbrother of cloud-init. 😭 tiny stepbrother. i'm obsessed.


✨ OPTIONS ✨

  • -c /path/to/config, --config /path/to/config β€” configuration directory containing context for rendering (default: /etc/ionit) πŸ—‚οΈ
  • -t /path/to/templates, --templates /path/to/templates β€” directory to search for Jinja templates (default: /etc) πŸ”
  • -e TEMPLATE_EXTENSION, --template-extension TEMPLATE_EXTENSION β€” extension to look for in the template directory (default: jinja) πŸŽ€
  • --debug β€” print debug output πŸ›
  • -q, --quiet β€” decrease output verbosity to warnings and errors. she goes quiet, she's just observing 🀫

✨ PYTHON MODULES ✨

okay this part is lowkey the coolest part, so pay attention bestie πŸ’œ

Python modules can define a collect_context function. this function is called by ionit, and the current context is passed as a parameter. you can use the current context to derive more context information, but this variable should not be modified. do not touch. hands off. πŸ™ˆ

collect_context must return a dictionary (can be empty) or raise an exception β€” which will be caught by ionit. so you're safe either way, she's not gonna crash on you. 🫢

Python modules can also define functions which can be called from the Jinja template on rendering. use the ionit_plugin.function decorator to mark the functions to export. that decorator is the little glow-up that says "yes, this one goes in the template" ✨

⚠️ note that the function names should not collide with other keys from the context. if one Python module defines a function and a value in the context with the same name, the value in the context will take precedence. context wins. always. sorry to your function, she got outshined πŸ’€

an example Python module might look like:

import ionit_plugin

@ionit_plugin.function
def double(value):
    return 2 * value

@ionit_plugin.function
def example_function():
    return "Lorem ipsum"

def collect_context(current_context):
    return {"key": "value"}

look at her. double, example_function, collect_context β€” all doing their little jobs, all thriving. "Lorem ipsum" really said placeholder text but make it fashion 🌸


✨ AUTHOR ✨

Benjamin Drung bdrung@posteo.de πŸ‘‘


and that's the whole page, bestie!! πŸ’– this was ionit's Manual, dated 2018-08-13, and yeah the footer says version ionit too β€” so go forth, render those templates, and remember: alphabetical order, last key wins, don't modify the context. slay πŸŒˆβ­πŸ’…

πŸ“¦ where this page comes from