No description
Find a file
2023-01-25 22:48:13 +01:00
doc add certificate support 2023-01-25 22:48:13 +01:00
src/rougail add certificate support 2023-01-25 22:48:13 +01:00
tests add certificate support 2023-01-25 22:48:13 +01:00
.gitignore first cadoles' version 2019-11-24 20:25:09 +01:00
LICENSE add license 2022-03-08 20:42:29 +01:00
logo.png update logo 2022-11-11 11:04:31 +01:00
logo.svg add schema 2022-11-11 15:52:39 +01:00
README.md update documentation 2022-11-10 22:58:24 +01:00
setup.py Add silique copyright 2022-11-02 23:00:42 +01:00

Logo Rougail

Rougail

Description

Rougail is a free full-featured configuration manager library written in python3.

The configuration is describe in YAML ou XML dictionary files.

Those dictionaries are converted into Tiramisu objects and can generates configuration files with template written in Cheetah or Jinja.

Rougail can be incorporated with other technologies and stacks regardless of whether theyre written in Python or not.

Simple example

Create directories:

# mkdir dict tmpl tmp dest

Dictionary

A dictionary is a services and a variables description file.

Create the file dict/dictionary.yml:

version: '0.10'

# describe a first service with a single file
services:
- service:
  - name: my_service
    file:
    - engine: jinja
      text: /etc/filename

# describe a variable my_first_variable
# and a family with a variable my_second_variable
variables:
- variable:
  - name: my_first_variable
    value:
    - text: my_value
- family:
  - name: my_family
    variables:
    - variable:
      - name: my_second_variable
        type: number
        mandatory: true
        value:
        - text: 1

Template

Create a Jinja template tmpl/filename:

My first value: {{ my_first_variable }}
My second value: {{ my_second_variable }}

Generate template

With default value:

Here is a python3 example file:

from rougail import Rougail, RougailConfig
from asyncio import run

async def main():
    RougailConfig['dictionaries_dir'] = ['dict']
    RougailConfig['templates_dir'] = ['tmpl']
    RougailConfig['tmp_dir'] = 'tmp'
    RougailConfig['destinations_dir'] = 'dest'
    rougail = Rougail()
    await rougail.template()

run(main())

The destination file is generated:

# cat dest/etc/filename
My first value: my_value
My second value: 1

With modified value

Remove old generated file:

# rm -f dest/etc/filename

Use Tiramisu API to change values:

from rougail import Rougail, RougailConfig
from asyncio import run

async def main():
    RougailConfig['dictionaries_dir'] = ['dict']
    RougailConfig['templates_dir'] = ['tmpl']
    RougailConfig['tmp_dir'] = 'tmp'
    RougailConfig['destinations_dir'] = 'dest'
    rougail = Rougail()
    config = await rougail.get_config()
    await config.option('rougail.my_first_variable').value.set('modified_value')
    await config.option('rougail.my_family.my_second_variable').value.set(2)
    await rougail.template()


run(main())

The destination file is generated with new values:

# cat dest/etc/filename
My first value: modified_value
My second value: 2

Link

Related projects