add jinja2 templating

This commit is contained in:
Emmanuel Garette 2021-02-20 18:01:13 +01:00
parent 807842e680
commit 20d8242d47
50 changed files with 292 additions and 47 deletions

View file

@ -34,4 +34,5 @@ Rougail est un bibliothèque python3 qui permet de charger des dictionnaires (fi
## Les templates
- Type creole
- Type jinja2
FIXME ^^

View file

@ -54,7 +54,7 @@ Le répertoire des templates est géré dans la clef "templates_dir" et a comme
## Le moteur de templates par défaut
Le moteur de template est géré dans la clef "default_engine" et a comme valeur par défaut : "creole". Les valeurs possible sont "none" ou "creole".
Le moteur de template est géré dans la clef "default_engine" et a comme valeur par défaut : "creole". Les valeurs possible sont "none", "creole" ou "jinja2".
## Le répertoire des patchs

View file

@ -138,8 +138,14 @@ Il est possible de redéfinir les éléments d'un fichier dans un dictionnaire d
Par défaut, le moteur de templating est le moteur de templating compatible avec "creole".
Aujourd'hui il est possible de désactiver la templatisation du fichier (il sera alors uniquement copié) :
Il est possible de désactiver la templatisation du fichier (il sera alors uniquement copié) :
```
<file engine="none">/etc/squid/squid.conf</file>
```
Ou d'utiliser le moteur "jinja2" :
```
<file engine="jinja2">/etc/squid/squid.conf</file>
```

View file

@ -30,8 +30,14 @@ Dans ce cas le fichier de destination aura le même nom.
Par défaut, le moteur de templating est le moteur de templating compatible avec "creole".
Aujourd'hui il est possible de désactiver la templatisation du fichier (il sera alors uniquement copié) :
Il est possible de désactiver la templatisation du fichier (il sera alors uniquement copié) :
```
<override engine="none"/>
```
Ou d'utiliser le moteur "jinja2" :
```
<override engine="jinja2"/>
```

View file

@ -66,11 +66,11 @@
<!ATTLIST file group CDATA "root">
<!ATTLIST file filelist CDATA #IMPLIED>
<!ATTLIST file redefine (True|False) "False">
<!ATTLIST file engine (none|creole) #IMPLIED>
<!ATTLIST file engine (none|creole|jinja2) #IMPLIED>
<!ELEMENT override EMPTY>
<!ATTLIST override source CDATA #IMPLIED>
<!ATTLIST override engine (none|creole) #IMPLIED>
<!ATTLIST override engine (none|creole|jinja2) #IMPLIED>
<!ELEMENT variables ((variable*|family*)*)>

View file

@ -1,4 +1,4 @@
from . import none, creole
from . import none, creole, jinja2
__all__ = ('none', 'creole')
__all__ = ('none', 'creole', 'jinja2')

View file

@ -0,0 +1,69 @@
"""Jinja2 engine
Created by:
EOLE (http://eole.orion.education.fr)
Copyright (C) 2005-2018
Forked by:
Cadoles (http://www.cadoles.com)
Copyright (C) 2021
distribued with GPL-2 or later license
This program is free software; 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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from typing import Any, Dict
from jinja2 import Environment, FileSystemLoader
from jinja2.exceptions import UndefinedError
from ...i18n import _
from ...utils import normalize_family
from ...error import TemplateError
def process(filename: str,
source: str,
true_destfilename: str,
destfilename: str,
variable: Any,
rougail_variables_dict: Dict,
eosfunc: Dict,
):
"""Process a cheetah template
"""
# full path of the destination file
dir_name, template_name = filename.rsplit('/', 1)
if source is not None: # pragma: no cover
raise TemplateError(_('source is not supported for jinja2'))
rougail_variables_dict['rougail_variable'] = variable
if variable is not None:
var = {'rougail_variable': variable}
else:
var = {}
try:
# extra_context = {'normalize_family': normalize_family,
# eosfunc
env = Environment(loader=FileSystemLoader(dir_name))
template = env.get_template(template_name)
data = template.render(**rougail_variables_dict, rougail_filename=true_destfilename, **var)
except UndefinedError as err: # pragma: no cover
varname = err
msg = f"Error: unknown variable used in template {filename} to {destfilename}: {varname}"
raise TemplateError(_(msg)) from err
if not data.endswith('\n'):
data = data + '\n'
with open(destfilename, 'w') as file_h:
file_h.write(data)

View file

@ -4,6 +4,7 @@
<services>
<service name="test">
<file>/etc/file</file>
<file engine="jinja2">/etc/file2</file>
</service>
</services>

View file

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "services.test.files.file.engine": "creole", "services.test.files.file.group": "root", "services.test.files.file.mode": "0644", "services.test.files.file.name": "/etc/file", "services.test.files.file.owner": "root", "services.test.files.file.source": "file", "services.test.files.file.activate": true}
{"rougail.general.mode_conteneur_actif": "non", "services.test.files.file.engine": "creole", "services.test.files.file.group": "root", "services.test.files.file.mode": "0644", "services.test.files.file.name": "/etc/file", "services.test.files.file.owner": "root", "services.test.files.file.source": "file", "services.test.files.file.activate": true, "services.test.files.file2.engine": "jinja2", "services.test.files.file2.group": "root", "services.test.files.file2.mode": "0644", "services.test.files.file2.name": "/etc/file2", "services.test.files.file2.owner": "root", "services.test.files.file2.source": "file2", "services.test.files.file2.activate": true}

View file

@ -0,0 +1,2 @@
non
non

View file

@ -1,2 +1,4 @@
C /etc/file 0644 root root - /usr/local/lib/etc/file
z /etc/file - - - - -
C /etc/file2 0644 root root - /usr/local/lib/etc/file2
z /etc/file2 - - - - -

View file

@ -22,7 +22,15 @@ option_12 = StrOption(name="owner", doc="owner", default="root")
option_13 = StrOption(name="source", doc="source", default="file")
option_14 = BoolOption(name="activate", doc="activate", default=True)
option_7 = OptionDescription(name="file", doc="file", children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14])
option_6 = OptionDescription(name="files", doc="files", children=[option_7])
option_16 = StrOption(name="engine", doc="engine", default="jinja2")
option_17 = StrOption(name="group", doc="group", default="root")
option_18 = StrOption(name="mode", doc="mode", default="0644")
option_19 = FilenameOption(name="name", doc="name", default="/etc/file2")
option_20 = StrOption(name="owner", doc="owner", default="root")
option_21 = StrOption(name="source", doc="source", default="file2")
option_22 = BoolOption(name="activate", doc="activate", default=True)
option_15 = OptionDescription(name="file2", doc="file2", children=[option_16, option_17, option_18, option_19, option_20, option_21, option_22])
option_6 = OptionDescription(name="files", doc="files", children=[option_7, option_15])
option_5 = OptionDescription(name="test", doc="test", children=[option_6])
option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])

View file

@ -0,0 +1,2 @@
{{ mode_conteneur_actif }}
{{ rougail.general.mode_conteneur_actif }}

View file

@ -4,6 +4,7 @@
<services>
<service name="test">
<file>/etc/systemd-makefs@dev-disk-by\x2dpartlabel</file>
<file engine="jinja2">/etc/systemd-makefs@dev-disk-by\x2dpartlabel2</file>
</service>
</services>

View file

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.engine": "creole", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.group": "root", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.mode": "0644", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.name": "/etc/systemd-makefs@dev-disk-by\\x2dpartlabel", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.owner": "root", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.source": "systemd-makefs@dev-disk-by\\x2dpartlabel", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.activate": true}
{"rougail.general.mode_conteneur_actif": "non", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.engine": "creole", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.group": "root", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.mode": "0644", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.name": "/etc/systemd-makefs@dev-disk-by\\x2dpartlabel", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.owner": "root", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.source": "systemd-makefs@dev-disk-by\\x2dpartlabel", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel.activate": true, "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.engine": "jinja2", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.group": "root", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.mode": "0644", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.name": "/etc/systemd-makefs@dev-disk-by\\x2dpartlabel2", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.owner": "root", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.source": "systemd-makefs@dev-disk-by\\x2dpartlabel2", "services.test.files.systemd_makefs@dev_disk_by\\x2dpartlabel2.activate": true}

View file

@ -1,2 +1,4 @@
C /etc/systemd-makefs@dev-disk-by\x2dpartlabel 0644 root root - /usr/local/lib/etc/systemd-makefs@dev-disk-by\x2dpartlabel
z /etc/systemd-makefs@dev-disk-by\x2dpartlabel - - - - -
C /etc/systemd-makefs@dev-disk-by\x2dpartlabel2 0644 root root - /usr/local/lib/etc/systemd-makefs@dev-disk-by\x2dpartlabel2
z /etc/systemd-makefs@dev-disk-by\x2dpartlabel2 - - - - -

View file

@ -22,7 +22,15 @@ option_12 = StrOption(name="owner", doc="owner", default="root")
option_13 = StrOption(name="source", doc="source", default="systemd-makefs@dev-disk-by\\x2dpartlabel")
option_14 = BoolOption(name="activate", doc="activate", default=True)
option_7 = OptionDescription(name="systemd_makefs@dev_disk_by\\x2dpartlabel", doc="systemd-makefs@dev-disk-by\\x2dpartlabel", children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14])
option_6 = OptionDescription(name="files", doc="files", children=[option_7])
option_16 = StrOption(name="engine", doc="engine", default="jinja2")
option_17 = StrOption(name="group", doc="group", default="root")
option_18 = StrOption(name="mode", doc="mode", default="0644")
option_19 = FilenameOption(name="name", doc="name", default="/etc/systemd-makefs@dev-disk-by\\x2dpartlabel2")
option_20 = StrOption(name="owner", doc="owner", default="root")
option_21 = StrOption(name="source", doc="source", default="systemd-makefs@dev-disk-by\\x2dpartlabel2")
option_22 = BoolOption(name="activate", doc="activate", default=True)
option_15 = OptionDescription(name="systemd_makefs@dev_disk_by\\x2dpartlabel2", doc="systemd-makefs@dev-disk-by\\x2dpartlabel2", children=[option_16, option_17, option_18, option_19, option_20, option_21, option_22])
option_6 = OptionDescription(name="files", doc="files", children=[option_7, option_15])
option_5 = OptionDescription(name="test", doc="test", children=[option_6])
option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])

View file

@ -0,0 +1 @@
{{ mode_conteneur_actif }}

View file

@ -5,6 +5,9 @@
<service name="test">
<override/>
</service>
<service name="test2">
<override engine="jinja2"/>
</service>
</services>
<variables>

View file

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "services.test.overrides.test_service.engine": "creole", "services.test.overrides.test_service.name": "test", "services.test.overrides.test_service.source": "test.service", "services.test.overrides.test_service.activate": true}
{"rougail.general.mode_conteneur_actif": "non", "services.test.overrides.test_service.engine": "creole", "services.test.overrides.test_service.name": "test", "services.test.overrides.test_service.source": "test.service", "services.test.overrides.test_service.activate": true, "services.test2.overrides.test2_service.engine": "jinja2", "services.test2.overrides.test2_service.name": "test2", "services.test2.overrides.test2_service.source": "test2.service", "services.test2.overrides.test2_service.activate": true}

View file

@ -21,5 +21,12 @@ option_11 = BoolOption(name="activate", doc="activate", default=True)
option_7 = OptionDescription(name="test_service", doc="test.service", children=[option_8, option_9, option_10, option_11])
option_6 = OptionDescription(name="overrides", doc="overrides", children=[option_7])
option_5 = OptionDescription(name="test", doc="test", children=[option_6])
option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
option_15 = StrOption(name="engine", doc="engine", default="jinja2")
option_16 = StrOption(name="name", doc="name", default="test2")
option_17 = StrOption(name="source", doc="source", default="test2.service")
option_18 = BoolOption(name="activate", doc="activate", default=True)
option_14 = OptionDescription(name="test2_service", doc="test2.service", children=[option_15, option_16, option_17, option_18])
option_13 = OptionDescription(name="overrides", doc="overrides", children=[option_14])
option_12 = OptionDescription(name="test2", doc="test2", children=[option_13])
option_4 = OptionDescription(name="services", doc="services", children=[option_5, option_12], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])

View file

@ -0,0 +1 @@
{{ mode_conteneur_actif }}

View file

@ -3,6 +3,7 @@
<services>
<service name='test'>
<file>/etc/mailname</file>
<file engine="jinja2">/etc/mailname2</file>
</service>
</services>
<variables>

View file

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.condition": "oui", "rougail.general.leader.leader": [{"rougail.general.leader.leader": "a", "rougail.general.leader.follower2": null}, {"rougail.general.leader.leader": "b", "rougail.general.leader.follower1": null, "rougail.general.leader.follower2": null}], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.activate": true}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.condition": "oui", "rougail.general.leader.leader": [{"rougail.general.leader.leader": "a", "rougail.general.leader.follower2": null}, {"rougail.general.leader.leader": "b", "rougail.general.leader.follower1": null, "rougail.general.leader.follower2": null}], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.activate": true, "services.test.files.mailname2.engine": "jinja2", "services.test.files.mailname2.group": "root", "services.test.files.mailname2.mode": "0644", "services.test.files.mailname2.name": "/etc/mailname2", "services.test.files.mailname2.owner": "root", "services.test.files.mailname2.source": "mailname2", "services.test.files.mailname2.activate": true}

View file

@ -0,0 +1,5 @@
leader: a
follower2:
leader: b
follower1:
follower2:

View file

@ -1,2 +1,4 @@
C /etc/mailname 0644 root root - /usr/local/lib/etc/mailname
z /etc/mailname - - - - -
C /etc/mailname2 0644 root root - /usr/local/lib/etc/mailname2
z /etc/mailname2 - - - - -

View file

@ -27,7 +27,15 @@ option_17 = StrOption(name="owner", doc="owner", default="root")
option_18 = StrOption(name="source", doc="source", default="mailname")
option_19 = BoolOption(name="activate", doc="activate", default=True)
option_12 = OptionDescription(name="mailname", doc="mailname", children=[option_13, option_14, option_15, option_16, option_17, option_18, option_19])
option_11 = OptionDescription(name="files", doc="files", children=[option_12])
option_21 = StrOption(name="engine", doc="engine", default="jinja2")
option_22 = StrOption(name="group", doc="group", default="root")
option_23 = StrOption(name="mode", doc="mode", default="0644")
option_24 = FilenameOption(name="name", doc="name", default="/etc/mailname2")
option_25 = StrOption(name="owner", doc="owner", default="root")
option_26 = StrOption(name="source", doc="source", default="mailname2")
option_27 = BoolOption(name="activate", doc="activate", default=True)
option_20 = OptionDescription(name="mailname2", doc="mailname2", children=[option_21, option_22, option_23, option_24, option_25, option_26, option_27])
option_11 = OptionDescription(name="files", doc="files", children=[option_12, option_20])
option_10 = OptionDescription(name="test", doc="test", children=[option_11])
option_9 = OptionDescription(name="services", doc="services", children=[option_10], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_9])

View file

@ -0,0 +1,9 @@
{% for lead in leader -%}
leader: {{ lead }}
{% if lead.follower1 is defined -%}
follower1: {{ lead.follower1 if lead.follower1 }}
{% endif -%}
{% if lead.follower2 is defined -%}
follower2: {{ lead.follower2 if lead.follower2 }}
{% endif -%}
{% endfor -%}

View file

@ -3,6 +3,7 @@
<services>
<service name='test'>
<file>/etc/mailname</file>
<file engine="jinja2">/etc/mailname2</file>
</service>
</services>
<variables>

View file

@ -1 +1 @@
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.activer_ejabberd": "non", "extra.ejabberd.description.description": [{"extra.ejabberd.description.description": "test", "extra.ejabberd.description.mode": "pre"}], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.activate": true}
{"rougail.general.mode_conteneur_actif": "non", "rougail.general.activer_ejabberd": "non", "extra.ejabberd.description.description": [{"extra.ejabberd.description.description": "test", "extra.ejabberd.description.mode": "pre"}], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": "/etc/mailname", "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.activate": true, "services.test.files.mailname2.engine": "jinja2", "services.test.files.mailname2.group": "root", "services.test.files.mailname2.mode": "0644", "services.test.files.mailname2.name": "/etc/mailname2", "services.test.files.mailname2.owner": "root", "services.test.files.mailname2.source": "mailname2", "services.test.files.mailname2.activate": true}

View file

@ -0,0 +1,11 @@
contain test
1
leader: test
follower: pre
supeq
sup
diff
testpre
pretest
leader2: test
follower2: pre

View file

@ -1,2 +1,4 @@
C /etc/mailname 0644 root root - /usr/local/lib/etc/mailname
z /etc/mailname - - - - -
C /etc/mailname2 0644 root root - /usr/local/lib/etc/mailname2
z /etc/mailname2 - - - - -

View file

@ -28,7 +28,15 @@ option_18 = StrOption(name="owner", doc="owner", default="root")
option_19 = StrOption(name="source", doc="source", default="mailname")
option_20 = BoolOption(name="activate", doc="activate", default=True)
option_13 = OptionDescription(name="mailname", doc="mailname", children=[option_14, option_15, option_16, option_17, option_18, option_19, option_20])
option_12 = OptionDescription(name="files", doc="files", children=[option_13])
option_22 = StrOption(name="engine", doc="engine", default="jinja2")
option_23 = StrOption(name="group", doc="group", default="root")
option_24 = StrOption(name="mode", doc="mode", default="0644")
option_25 = FilenameOption(name="name", doc="name", default="/etc/mailname2")
option_26 = StrOption(name="owner", doc="owner", default="root")
option_27 = StrOption(name="source", doc="source", default="mailname2")
option_28 = BoolOption(name="activate", doc="activate", default=True)
option_21 = OptionDescription(name="mailname2", doc="mailname2", children=[option_22, option_23, option_24, option_25, option_26, option_27, option_28])
option_12 = OptionDescription(name="files", doc="files", children=[option_13, option_21])
option_11 = OptionDescription(name="test", doc="test", children=[option_12])
option_10 = OptionDescription(name="services", doc="services", children=[option_11], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_5, option_10])

View file

@ -0,0 +1,33 @@
{% if 'test' in extra.ejabberd.description -%}
contain test
{% endif -%}
{{ extra.ejabberd.description|length }}
{% if 'a' in extra.ejabberd.description -%}
contain a
{% endif -%}
{% for description in extra.ejabberd.description -%}
leader: {{ description }}
follower: {{ description.mode }}
{% if description <= description.mode -%}
infeq
{% endif -%}
{% if description >= description.mode -%}
supeq
{% endif -%}
{% if description < description.mode -%}
inf
{% endif -%}
{% if description > description.mode -%}
sup
{% endif -%}
{% if description == description.mode -%}
eq
{% endif -%}
{% if description != description.mode -%}
diff
{% endif -%}
{{ description + description.mode }}
{{ description.mode + description }}
{% endfor -%}
leader2: {{ extra.ejabberd.description[0] }}
follower2: {{ extra.ejabberd.description[0].mode }}

View file

@ -3,6 +3,7 @@
<services>
<service name='test'>
<file file_type="variable" source="mailname">file_name</file>
<file file_type="variable" source="mailname2" engine="jinja2">file_name2</file>
</service>
</services>
<variables>
@ -10,5 +11,9 @@
<value>/etc/mailname</value>
<value>/etc/mailname2</value>
</variable>
<variable name='file_name2' type='filename' multi='True'>
<value>/etc/mailname3</value>
<value>/etc/mailname4</value>
</variable>
</variables>
</rougail>

View file

@ -1 +1 @@
{"rougail.file_name": ["/etc/mailname", "/etc/mailname2"], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": ["/etc/mailname", "/etc/mailname2"], "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.activate": true}
{"rougail.file_name": ["/etc/mailname", "/etc/mailname2"], "rougail.file_name2": ["/etc/mailname3", "/etc/mailname4"], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": ["/etc/mailname", "/etc/mailname2"], "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.activate": true, "services.test.files.mailname2.engine": "jinja2", "services.test.files.mailname2.group": "root", "services.test.files.mailname2.mode": "0644", "services.test.files.mailname2.name": ["/etc/mailname3", "/etc/mailname4"], "services.test.files.mailname2.owner": "root", "services.test.files.mailname2.source": "mailname2", "services.test.files.mailname2.activate": true}

View file

@ -0,0 +1 @@
/etc/mailname3

View file

@ -0,0 +1 @@
/etc/mailname4

View file

@ -2,3 +2,7 @@ C /etc/mailname 0644 root root - /usr/local/lib/etc/mailname
z /etc/mailname - - - - -
C /etc/mailname2 0644 root root - /usr/local/lib/etc/mailname2
z /etc/mailname2 - - - - -
C /etc/mailname3 0644 root root - /usr/local/lib/etc/mailname3
z /etc/mailname3 - - - - -
C /etc/mailname4 0644 root root - /usr/local/lib/etc/mailname4
z /etc/mailname4 - - - - -

View file

@ -12,16 +12,25 @@ try:
except:
from tiramisu import *
option_2 = FilenameOption(name="file_name", doc="file_name", multi=True, default=['/etc/mailname', '/etc/mailname2'], default_multi="/etc/mailname", properties=frozenset({"mandatory", "normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_7 = StrOption(name="engine", doc="engine", default="creole")
option_8 = StrOption(name="group", doc="group", default="root")
option_9 = StrOption(name="mode", doc="mode", default="0644")
option_10 = SymLinkOption(name="name", opt=option_2)
option_11 = StrOption(name="owner", doc="owner", default="root")
option_12 = StrOption(name="source", doc="source", default="mailname")
option_13 = BoolOption(name="activate", doc="activate", default=True)
option_6 = OptionDescription(name="mailname", doc="mailname", children=[option_7, option_8, option_9, option_10, option_11, option_12, option_13])
option_5 = OptionDescription(name="files", doc="files", children=[option_6])
option_4 = OptionDescription(name="test", doc="test", children=[option_5])
option_3 = OptionDescription(name="services", doc="services", children=[option_4], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_3])
option_3 = FilenameOption(name="file_name2", doc="file_name2", multi=True, default=['/etc/mailname3', '/etc/mailname4'], default_multi="/etc/mailname3", properties=frozenset({"mandatory", "normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_8 = StrOption(name="engine", doc="engine", default="creole")
option_9 = StrOption(name="group", doc="group", default="root")
option_10 = StrOption(name="mode", doc="mode", default="0644")
option_11 = SymLinkOption(name="name", opt=option_2)
option_12 = StrOption(name="owner", doc="owner", default="root")
option_13 = StrOption(name="source", doc="source", default="mailname")
option_14 = BoolOption(name="activate", doc="activate", default=True)
option_7 = OptionDescription(name="mailname", doc="mailname", children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14])
option_16 = StrOption(name="engine", doc="engine", default="jinja2")
option_17 = StrOption(name="group", doc="group", default="root")
option_18 = StrOption(name="mode", doc="mode", default="0644")
option_19 = SymLinkOption(name="name", opt=option_3)
option_20 = StrOption(name="owner", doc="owner", default="root")
option_21 = StrOption(name="source", doc="source", default="mailname2")
option_22 = BoolOption(name="activate", doc="activate", default=True)
option_15 = OptionDescription(name="mailname2", doc="mailname2", children=[option_16, option_17, option_18, option_19, option_20, option_21, option_22])
option_6 = OptionDescription(name="files", doc="files", children=[option_7, option_15])
option_5 = OptionDescription(name="test", doc="test", children=[option_6])
option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])

View file

@ -0,0 +1 @@
{{ rougail_filename }}

View file

@ -3,6 +3,7 @@
<services>
<service name='test'>
<file file_type="variable" source="mailname" variable="var">file_name</file>
<file file_type="variable" source="mailname2" variable="var" engine="jinja2">file_name2</file>
</service>
</services>
<variables>
@ -10,6 +11,10 @@
<value>/etc/mailname</value>
<value>/etc/mailname2</value>
</variable>
<variable name='file_name2' type='filename' multi='True'>
<value>/etc/mailname3</value>
<value>/etc/mailname4</value>
</variable>
<variable name='var' type='string' multi='True'>
<value>mailname</value>
<value>mailname2</value>

View file

@ -1 +1 @@
{"rougail.file_name": ["/etc/mailname", "/etc/mailname2"], "rougail.var": ["mailname", "mailname2"], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": ["/etc/mailname", "/etc/mailname2"], "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.variable": ["mailname", "mailname2"], "services.test.files.mailname.activate": true}
{"rougail.file_name": ["/etc/mailname", "/etc/mailname2"], "rougail.file_name2": ["/etc/mailname3", "/etc/mailname4"], "rougail.var": ["mailname", "mailname2"], "services.test.files.mailname.engine": "creole", "services.test.files.mailname.group": "root", "services.test.files.mailname.mode": "0644", "services.test.files.mailname.name": ["/etc/mailname", "/etc/mailname2"], "services.test.files.mailname.owner": "root", "services.test.files.mailname.source": "mailname", "services.test.files.mailname.variable": ["mailname", "mailname2"], "services.test.files.mailname.activate": true, "services.test.files.mailname2.engine": "jinja2", "services.test.files.mailname2.group": "root", "services.test.files.mailname2.mode": "0644", "services.test.files.mailname2.name": ["/etc/mailname3", "/etc/mailname4"], "services.test.files.mailname2.owner": "root", "services.test.files.mailname2.source": "mailname2", "services.test.files.mailname2.variable": ["mailname", "mailname2"], "services.test.files.mailname2.activate": true}

View file

@ -2,3 +2,7 @@ C /etc/mailname 0644 root root - /usr/local/lib/etc/mailname
z /etc/mailname - - - - -
C /etc/mailname2 0644 root root - /usr/local/lib/etc/mailname2
z /etc/mailname2 - - - - -
C /etc/mailname3 0644 root root - /usr/local/lib/etc/mailname3
z /etc/mailname3 - - - - -
C /etc/mailname4 0644 root root - /usr/local/lib/etc/mailname4
z /etc/mailname4 - - - - -

View file

@ -12,18 +12,28 @@ try:
except:
from tiramisu import *
option_2 = FilenameOption(name="file_name", doc="file_name", multi=True, default=['/etc/mailname', '/etc/mailname2'], default_multi="/etc/mailname", properties=frozenset({"mandatory", "normal"}))
option_3 = StrOption(name="var", doc="var", multi=True, default=['mailname', 'mailname2'], default_multi="mailname", properties=frozenset({"mandatory", "normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3])
option_8 = StrOption(name="engine", doc="engine", default="creole")
option_9 = StrOption(name="group", doc="group", default="root")
option_10 = StrOption(name="mode", doc="mode", default="0644")
option_11 = SymLinkOption(name="name", opt=option_2)
option_12 = StrOption(name="owner", doc="owner", default="root")
option_13 = StrOption(name="source", doc="source", default="mailname")
option_14 = SymLinkOption(name="variable", opt=option_3)
option_15 = BoolOption(name="activate", doc="activate", default=True)
option_7 = OptionDescription(name="mailname", doc="mailname", children=[option_8, option_9, option_10, option_11, option_12, option_13, option_14, option_15])
option_6 = OptionDescription(name="files", doc="files", children=[option_7])
option_5 = OptionDescription(name="test", doc="test", children=[option_6])
option_4 = OptionDescription(name="services", doc="services", children=[option_5], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_4])
option_3 = FilenameOption(name="file_name2", doc="file_name2", multi=True, default=['/etc/mailname3', '/etc/mailname4'], default_multi="/etc/mailname3", properties=frozenset({"mandatory", "normal"}))
option_4 = StrOption(name="var", doc="var", multi=True, default=['mailname', 'mailname2'], default_multi="mailname", properties=frozenset({"mandatory", "normal"}))
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2, option_3, option_4])
option_9 = StrOption(name="engine", doc="engine", default="creole")
option_10 = StrOption(name="group", doc="group", default="root")
option_11 = StrOption(name="mode", doc="mode", default="0644")
option_12 = SymLinkOption(name="name", opt=option_2)
option_13 = StrOption(name="owner", doc="owner", default="root")
option_14 = StrOption(name="source", doc="source", default="mailname")
option_15 = SymLinkOption(name="variable", opt=option_4)
option_16 = BoolOption(name="activate", doc="activate", default=True)
option_8 = OptionDescription(name="mailname", doc="mailname", children=[option_9, option_10, option_11, option_12, option_13, option_14, option_15, option_16])
option_18 = StrOption(name="engine", doc="engine", default="jinja2")
option_19 = StrOption(name="group", doc="group", default="root")
option_20 = StrOption(name="mode", doc="mode", default="0644")
option_21 = SymLinkOption(name="name", opt=option_3)
option_22 = StrOption(name="owner", doc="owner", default="root")
option_23 = StrOption(name="source", doc="source", default="mailname2")
option_24 = SymLinkOption(name="variable", opt=option_4)
option_25 = BoolOption(name="activate", doc="activate", default=True)
option_17 = OptionDescription(name="mailname2", doc="mailname2", children=[option_18, option_19, option_20, option_21, option_22, option_23, option_24, option_25])
option_7 = OptionDescription(name="files", doc="files", children=[option_8, option_17])
option_6 = OptionDescription(name="test", doc="test", children=[option_7])
option_5 = OptionDescription(name="services", doc="services", children=[option_6], properties=frozenset({"hidden"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_5])

View file

@ -0,0 +1 @@
{{ rougail_variable }}