Configuration management

Configuration file format

Normally, the format should be readable for both humans and computers. It should be usable indepent of programming language. But how to pick one from the never ending list of options: json, yaml, toml, xml, ini etc. ?

There is one important limitation though: it’s not a programming language. All those lack the expressiveness of one. This means we don’t have mechanisms to avoid repetetions or validate data easily. A potential solution to this is the newly introduced format of pkl. Read more.

Order of precedence for resolving arguments

  1. Command line.
  2. Config file thats name is declared on the command line.
  3. Environment vars
  4. Local config file
  5. Global config file

Specifying configuration files

Specify as argument or flag

man hostname:

When called with one argument or with the –file option, the commands set the host name or the NIS/YP domain name.

Look for a specific filename

man make:

make executes commands in the makefile to update one or more target names, where name is typically a program. If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.

Use if it’s project configuration that needs version control. Otherwise prefer explicit over implicit and expect file path.

Load from default path

man podman:

CONFIGURATION FILES containers.conf (/usr/share/containers/containers.conf, /etc/containers/containers.conf, $HOME/.config/containers/containers.conf)

Use if it’s specific for a system. Don’t forget to ship a default configuration file. Add flags that can be used to skip all initializations (by giving the name “none”).

Command line options

Terminology: positional arguments and options(flags)

Frequently used Unix options

clig.dev

The art of command line

#sw #configuration