Templating Engine

Share your tips or issues concerning the WAPT Console or WAPT Agent here
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
User avatar
Aguay
Messages: 27
Registration: May 22, 2015 - 4:20 p.m.

October 3, 2016 - 5:19 PM

Hello,

I'd like to know if there's some kind of templating engine.

For example, in a configuration file, you could put "{{ hostname }}" and it would retrieve the hostname.

This would allow for the generation of unique configuration files for each workstation. I haven't found much information on this. If anyone has any, I'd be interested.

And even if some people have workarounds, I'd be interested too.

Thanks in advance!
User avatar
Aguay
Messages: 27
Registration: May 22, 2015 - 4:20 p.m.

October 5, 2016 - 11:50

I'm going to answer myself in order to perhaps help other users :)

Jinja2 is present on each machine with the clients, so it is possible to use this library to create configuration templates.

Here is an excerpt from the package using Jinja2:

Code: Select all

from jinja2 import Environment, FileSystemLoader

THIS_DIR = os.getcwd()
j2_env = Environment(loader=FileSystemLoader(THIS_DIR),
                         trim_blocks=True)
template = j2_env.get_template('template.yml')
file = open('config.yml', 'w')
file.write(template.render(value="Une valeur"))
file.close()
And in my template.yml file there's something like this:

Code: Select all

# template.yml

server_url: https://exemple.com
agent_name : {{ value }}
Therefore, during execution, we can put a variable in the field of the value to be applied to the template.

This is a very simple example, but it might help ;)
Ekouyoja
Messages: 18
Registration: July 18, 2016 - 10:35

October 26, 2016 - 2:31 PM

Thanks for the info, I didn't even know it included Jinja2 to be able to make templates, which can be very useful for managing workstations. :D
Locked