Reduce connections in diagram
This commit is contained in:
parent
4608081fba
commit
d6c2dd419a
2 changed files with 35 additions and 34 deletions
|
@ -15,16 +15,25 @@ external: {
|
|||
}
|
||||
}
|
||||
|
||||
{% for host in hosts %}
|
||||
{{ host.key }}: {
|
||||
}
|
||||
|
||||
{{ host.key }}.backup -> external.restic {
|
||||
classes: {
|
||||
zero_grid: {
|
||||
grid-columns: 3
|
||||
grid-gap: 0
|
||||
}
|
||||
monitored: {
|
||||
style: {
|
||||
stroke: "#0f0"
|
||||
stroke-dash: 3
|
||||
fill: "#1E9025"
|
||||
}
|
||||
}
|
||||
backup: {
|
||||
style: {
|
||||
fill: "#0f0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{% for host in hosts %}
|
||||
{{ host.key }}
|
||||
{% endfor %}{# host #}
|
||||
|
||||
{% for svc in svcs %}
|
||||
|
@ -36,32 +45,25 @@ external: {
|
|||
}
|
||||
|
||||
{% for backup in svc.backup or [] %}
|
||||
{{ svc.key }} -> {{ svc.host_key }}.backup: {{ backup.name }} {
|
||||
style: {
|
||||
stroke: "#0f0"
|
||||
stroke-dash: 3
|
||||
}
|
||||
}
|
||||
{% endfor %}{# backup #}
|
||||
{{ svc.key }}.'{{ backup.name }}'.class: backup
|
||||
{% endfor %}
|
||||
|
||||
{% if svc.monitoring %}
|
||||
{{ monitoring_key }} -> {{ svc.key }}: {
|
||||
style.stroke: "#1E9025"
|
||||
}
|
||||
{{ svc.key }}.monitored.class: monitored
|
||||
{% endif %}
|
||||
|
||||
{% if svc.database %}
|
||||
{{ svc.key }} -> {{ db_key }}: {
|
||||
style.stroke: "#336791"
|
||||
}
|
||||
{{ db_key }}.{{ svc.name }}
|
||||
{{ db_subkey }}.{{ svc.name }}
|
||||
{% endif %}
|
||||
|
||||
{% if svc.auth %}
|
||||
{{ svc.key }} -> {{ auth_key }}: {
|
||||
style.stroke: "#FD4B2D"
|
||||
}
|
||||
{{ auth_key }}.{{ svc.name }}
|
||||
{{ auth_subkey }}.{{ svc.name }}
|
||||
{% endif %}
|
||||
|
||||
{% if svc.s3 %}
|
||||
|
@ -78,14 +80,11 @@ external.scaleway.s3.{{ svc.name }}
|
|||
{{ svc.key }} -> {{ mail_key }}: {
|
||||
style.stroke: "#C9B81F"
|
||||
}
|
||||
{{ mail_key }}.{{ svc.name }}
|
||||
{{ mail_subkey }}.{{ svc.name }}
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}{# svc #}
|
||||
|
||||
{% for svc in grid_svcs %}
|
||||
{{ svc }}: {
|
||||
grid-columns: 3
|
||||
grid-gap: 0
|
||||
}
|
||||
{{ svc }}.class: zero_grid
|
||||
{% endfor %}
|
||||
|
|
20
visualize.py
20
visualize.py
|
@ -11,6 +11,7 @@ icon_overrides = {
|
|||
"backup": "restic",
|
||||
"dokku": None,
|
||||
"extra_services": None,
|
||||
"factorio": None,
|
||||
"forgejo_runner": "forgejo",
|
||||
"healthcheck": "healthchecks",
|
||||
"lego": "lets-encrypt",
|
||||
|
@ -96,20 +97,21 @@ if __name__ == '__main__':
|
|||
with open('./services.auto.tfvars', 'r') as file:
|
||||
services = hcl2.load(file)["services"][0]
|
||||
|
||||
db_key = service_key_find("postgresql", services, hosts)
|
||||
auth_key = service_key_find("authentik", services, hosts)
|
||||
monitoring_key = service_key_find("gatus", services, hosts)
|
||||
mail_key = service_key_find("mailcowdockerized", services, hosts)
|
||||
keys = {}
|
||||
keys["db_key"] = service_key_find("postgresql", services, hosts)
|
||||
keys["db_subkey"] = f"{keys["db_key"]}.dbs"
|
||||
keys["auth_key"] = service_key_find("authentik", services, hosts)
|
||||
keys["auth_subkey"] = f"{keys["auth_key"]}.apps"
|
||||
keys["mail_key"] = service_key_find("mailcowdockerized", services, hosts)
|
||||
keys["mail_subkey"] = f"{keys["mail_key"]}.mailboxes"
|
||||
keys["monitoring_key"] = service_key_find("gatus", services, hosts)
|
||||
|
||||
jinja_loader = jinja2.FileSystemLoader(searchpath="./templates")
|
||||
jinja_env = jinja2.Environment(loader=jinja_loader)
|
||||
template = jinja_env.get_template("infrastructure.d2.j2")
|
||||
print(template.render(
|
||||
grid_svcs=[db_key, auth_key, mail_key],
|
||||
grid_svcs=[keys["db_subkey"], keys["auth_subkey"], keys["mail_subkey"]],
|
||||
svcs=parse_services(services, hosts),
|
||||
hosts=parse_hosts(hosts),
|
||||
db_key=db_key,
|
||||
auth_key=auth_key,
|
||||
monitoring_key=monitoring_key,
|
||||
mail_key=mail_key,
|
||||
**keys
|
||||
))
|
||||
|
|
Loading…
Reference in a new issue