UConf, a smart tool for managing config files
Project description
UConf is a small tool aiming to provide simple handling of configuration files for an heterogeneous computer set.
Its key concepts are:
Abstract host-specific config to common features (server, relay, …)
Host-specific configuration may range from a single-line change to a whole file rewrite
Configuration files are modified in place, not in the source - versionned - repository.
In other words, it provides the following features:
Map each host to a set of categories (e.g laptop, server, dev, remote, …)
For each category (or combination thereof), list the files to install and their destinations
For each file, conditionnally include some parts depending on the active categories
Usage
Configuration
First, create the folder structure:
$ cd ~/conf
$ mkdir .uconf
$ touch .uconf/config
Then, set a few settings:
# .uconf/config
[core]
# Install files to my home folder
target = ~/
[categories]
# The host names "myhostname" belongs to the 'shell' and 'x11' categories
myhostname: shell x11
[files]
# Hosts in the 'shell' category should install
# the 'shell/gitconfig' and 'ssh/config' files
shell: shell/gitconfig ssh/config
# Hosts in the 'shell' but not the 'work' category should install
# our authorized_keys
shell && !work: ssh/authorized_keys
[actions]
# Files located in ~/conf/ssh are parsed and written to ~/.ssh/
ssh/* = parse destdir=".ssh/"
# shell/gitconfig goes to ~/.gitconfig
shell/gitconfig = parse destdir="~/.gitconfig"
Files
The heart of uconf is its file processing engine.
On the surface, it is a simple preprocessor that will parse files based on the categories defined in the .uconf/config file.
In other words, if the file shell/gitconfig contains:
[user]
#@if work
name = Raphaël Barrois
email = raphael.barrois@example.org
#@else
name = Xelnor
email = raphael.barrois@polytechnique.org
#@endif
And is build on the myhostname from the above example, the output will be:
# ~/.gitconfig
[user]
name = Xelnor
email = raphael.barrois@polytechnique.org
Commands
Once your configuration folder is set up, basic commands will be:
$ cd ~/conf
$ uconf make
Building file shell/gitconfig (FileProcessingAction)
Building file ssh/config (FileProcessingAction)
Building file ssh/authorized_keys (FileProcessingAction)
If you have modified a file, just backport its changes:
$ cd ~/conf
$ uconf back shell/gitconfig
Backporting file shell/gitconfig (FileProcessingAction)
This will update the source file (~/conf/shell/gitconfig in this example) to incorporate the changes from the destination file (here, ~/.gitconfig).
This works even if the file contained branches, i.e if the source file was:
[user]
#@if work
name = Raphaël Barrois
email = raphael.barrois@example.org
#@else
name = Xelnor
email = raphael.barrois@polytechnique.org
#@endif
And the destination (on a non-work machine) was modified to read:
[user]
name = Raphaël "Xelnor" Barrois
email = raphael.barrois@polytechnique.org
Then the result of running uconf back shell/gitconfig will be:
[user]
#@if work
name = Raphaël Barrois
email = raphael.barrois@example.org
#@else
name = Raphaël "Xelnor" Barrois
email = raphael.barrois@polytechnique.org
#@endif
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file uconf-0.4.0.tar.gz
.
File metadata
- Download URL: uconf-0.4.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8a19b4b0df1426308216c46e1653fd18c7479f4785b267209e0e3d055eff7da |
|
MD5 | 8083e13ad32b5afc7835c108ade30d32 |
|
BLAKE2b-256 | e4d5ac551a1a1af86bd9d2fa6fc82e9067cbd31aafe63012df7efa09cc0c7cdd |
File details
Details for the file uconf-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: uconf-0.4.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2ac5e08fc1d1a3b6fc33a33cce7a6c39046fe4695a1011631c71544cdc3ef1 |
|
MD5 | 26fa16e603c16e6392ab281fc0ab97cc |
|
BLAKE2b-256 | 23585aeff53eaa8d060965f9bf8cc8c21491d672fa139db51e3b9dcacfae6bfd |