From 365fc9405d93931738fda6a29eb0c9ff331dd0bf Mon Sep 17 00:00:00 2001 From: janic Date: Tue, 18 Oct 2022 00:19:05 +0200 Subject: [PATCH] Example config --- config/config.py | 17 +++++++++++++++++ config/configfiles.py | 0 config/template.py | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 config/config.py create mode 100644 config/configfiles.py create mode 100755 config/template.py diff --git a/config/config.py b/config/config.py new file mode 100644 index 0000000..01d49ef --- /dev/null +++ b/config/config.py @@ -0,0 +1,17 @@ +# Checkout the Variables bellow +# Special lines: +# # => Comented lines, they get ignored by python +# #- => Optional Configuration lines + +# Variables + +## Database Variables +db = {} +#- db['root_pw'] = 'RootPassWord' +db['enabled'] = True +db['user'] = 'DBUser' +db['user_pw'] = 'DBUserPassWord' +db['db'] = 'Database Name' +#- db['data_path_mysql'] = '/var/lib/mysql' +#- db['data_path_mysql_backup'] = '/var/lib/mysql' +#- db['port'] = 3306 diff --git a/config/configfiles.py b/config/configfiles.py new file mode 100644 index 0000000..e69de29 diff --git a/config/template.py b/config/template.py new file mode 100755 index 0000000..e3179f6 --- /dev/null +++ b/config/template.py @@ -0,0 +1,27 @@ +from jinja2 import Environment, FileSystemLoader +import config +import os + +# Static Variables +templates_directory = 'src/templates' + +# Load Templates Directory +file_loader = FileSystemLoader(templates_directory) +env = Environment(loader=file_loader) + +# Template everyfile +def template(filename, target_path): + # Load Template + template = env.get_template(filename) + # Render Output + content = template.render(db=config.db) + # Write Template to file + filename_without_ext = os.path.splitext(filename)[0] + cooked_file = target_path+filename_without_ext + file = open(cooked_file, 'w') + file.write(content) + file.close() + +# Render the templates: +## Create Docker-Compose +template("docker-compose.yml.j2", "./src/")