handle domain templating

This commit is contained in:
jem 2019-11-06 18:16:37 +01:00
parent e0e773531a
commit c60e11328c
2 changed files with 11 additions and 4 deletions

View file

@ -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}"

View file

@ -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,