From c60e11328cb93097f5ca9f4bd1a50db276753444 Mon Sep 17 00:00:00 2001 From: jem Date: Wed, 6 Nov 2019 18:16:37 +0100 Subject: [PATCH] handle domain templating --- src/main/python/ddadevops/__init__.py | 2 +- src/main/python/ddadevops/dda_pallet.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/python/ddadevops/__init__.py b/src/main/python/ddadevops/__init__.py index bc8c0b0..f3e1088 100644 --- a/src/main/python/ddadevops/__init__.py +++ b/src/main/python/ddadevops/__init__.py @@ -5,7 +5,7 @@ terraform, dda-pallet, aws & hetzner-cloud. """ from .meissa_build import meissa_init_project, stage, hetzner_api_key, tf_import_name, tf_import_resource -from .dda_pallet import dda_write_target, dda_uberjar +from .dda_pallet import dda_write_target, dda_write_domain, dda_uberjar from .terraform import tf_copy_common, tf_plan, tf_import, tf_apply, tf_output, tf_destroy, tf_read_output_json __version__ = "${version}" \ No newline at end of file diff --git a/src/main/python/ddadevops/dda_pallet.py b/src/main/python/ddadevops/dda_pallet.py index aabe44e..5b41801 100644 --- a/src/main/python/ddadevops/dda_pallet.py +++ b/src/main/python/ddadevops/dda_pallet.py @@ -5,13 +5,20 @@ import string TARGET = 'target.edn' TEMPLATE_TARGET_CONTENT = string.Template(""" {:existing [{:node-name "k8s" - :node-ip "$ip"}] + :node-ip "$ipv4"}] :provisioning-user {:login "root"}} """) -def dda_write_target(ip): +def dda_write_target(ipv4): with open(TARGET, "w") as output_file: - output_file.write(TEMPLATE_TARGET_CONTENT.substitute({'ip' : ip})) + output_file.write(TEMPLATE_TARGET_CONTENT.substitute({'ipv4' : ipv4})) + +def dda_write_domain(domain_path, substitues): + with open(domain_path, "r") as input_file: + domain_input = input_file.read() + domain_template = string.Template(domain_input) + with open('out_' + domain_path, "w") as output_file: + output_file.write(domain_template.substitute(substitues)) def dda_uberjar(tenant, application, spec): cmd = ['java', '-jar', '../../../target/meissa-tenant-server.jar', '--targets', TARGET,