From fc83048b0247e222dd94bbf0430f99d58c5be418 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Sun, 23 Jun 2024 22:29:14 +0200 Subject: staging: move bottin and guichet to docker, sync with prod config --- cluster/prod/app/core/secrets.toml | 4 + cluster/prod/app/guichet/deploy/directory.hcl | 58 --------- cluster/prod/app/guichet/deploy/guichet.hcl | 58 +++++++++ .../staging/app/core/config/bottin/config.json.tpl | 26 ++++ cluster/staging/app/core/deploy/bottin.hcl | 100 ++++++++++++++++ cluster/staging/app/core/secrets.toml | 5 + .../app/directory/config/bottin/config.json.tpl | 26 ---- .../app/directory/config/guichet/config.json.tpl | 37 ------ cluster/staging/app/directory/deploy/directory.hcl | 133 --------------------- cluster/staging/app/directory/secrets.toml | 51 -------- .../app/guichet/config/guichet/config.json.tpl | 40 +++++++ cluster/staging/app/guichet/deploy/guichet.hcl | 58 +++++++++ cluster/staging/app/guichet/secrets.toml | 51 ++++++++ 13 files changed, 342 insertions(+), 305 deletions(-) delete mode 100644 cluster/prod/app/guichet/deploy/directory.hcl create mode 100644 cluster/prod/app/guichet/deploy/guichet.hcl create mode 100644 cluster/staging/app/core/config/bottin/config.json.tpl create mode 100644 cluster/staging/app/core/deploy/bottin.hcl delete mode 100644 cluster/staging/app/directory/config/bottin/config.json.tpl delete mode 100644 cluster/staging/app/directory/config/guichet/config.json.tpl delete mode 100644 cluster/staging/app/directory/deploy/directory.hcl delete mode 100644 cluster/staging/app/directory/secrets.toml create mode 100644 cluster/staging/app/guichet/config/guichet/config.json.tpl create mode 100644 cluster/staging/app/guichet/deploy/guichet.hcl create mode 100644 cluster/staging/app/guichet/secrets.toml (limited to 'cluster') diff --git a/cluster/prod/app/core/secrets.toml b/cluster/prod/app/core/secrets.toml index 736c9dd..8a6a7f2 100644 --- a/cluster/prod/app/core/secrets.toml +++ b/cluster/prod/app/core/secrets.toml @@ -3,3 +3,7 @@ type = 'user' description = 'LDAP base DN for everything' example = 'dc=example,dc=com' +[secrets."d53/gandi_api_key"] +type = 'user' +description = 'Gandi API key' + diff --git a/cluster/prod/app/guichet/deploy/directory.hcl b/cluster/prod/app/guichet/deploy/directory.hcl deleted file mode 100644 index 397602f..0000000 --- a/cluster/prod/app/guichet/deploy/directory.hcl +++ /dev/null @@ -1,58 +0,0 @@ -job "guichet" { - datacenters = [ "neptune", "scorpio" ] - type = "service" - priority = 90 - - group "guichet" { - count = 1 - - network { - port "web_port" { to = 9991 } - } - - task "guichet" { - driver = "docker" - config { - image = "dxflrs/guichet:m1gzk1r00xp0kz566fwbpc87z7haq7xj" - args = [ "server", "-config", "/etc/config.json" ] - readonly_rootfs = true - ports = [ "web_port" ] - volumes = [ - "secrets/config.json:/etc/config.json" - ] - } - - template { - data = file("../config/guichet/config.json.tpl") - destination = "secrets/config.json" - } - - resources { - memory = 200 - } - - service { - name = "guichet" - tags = [ - "guichet", - "tricot guichet.deuxfleurs.fr", - "d53-cname guichet.deuxfleurs.fr", - ] - port = "web_port" - address_mode = "host" - check { - type = "tcp" - port = "web_port" - interval = "60s" - timeout = "5s" - check_restart { - limit = 3 - grace = "90s" - ignore_warnings = false - } - } - } - } - } -} - diff --git a/cluster/prod/app/guichet/deploy/guichet.hcl b/cluster/prod/app/guichet/deploy/guichet.hcl new file mode 100644 index 0000000..4b2ff28 --- /dev/null +++ b/cluster/prod/app/guichet/deploy/guichet.hcl @@ -0,0 +1,58 @@ +job "guichet" { + datacenters = [ "neptune", "scorpio" ] + type = "service" + priority = 90 + + group "guichet" { + count = 1 + + network { + port "web_port" { to = 9991 } + } + + task "guichet" { + driver = "docker" + config { + image = "dxflrs/guichet:m1gzk1r00xp0kz566fwbpc87z7haq7xj" + args = [ "server", "-config", "/etc/config.json" ] + readonly_rootfs = true + ports = [ "web_port" ] + volumes = [ + "secrets/config.json:/etc/config.json" + ] + } + + template { + data = file("../config/guichet/config.json.tpl") + destination = "secrets/config.json" + } + + resources { + memory = 200 + } + + service { + name = "guichet" + tags = [ + "guichet", + "tricot guichet.deuxfleurs.fr", + "d53-cname guichet.deuxfleurs.fr", + ] + port = "web_port" + address_mode = "host" + check { + type = "tcp" + port = "web_port" + interval = "60s" + timeout = "5s" + check_restart { + limit = 3 + grace = "90s" + ignore_warnings = false + } + } + } + } + } +} + diff --git a/cluster/staging/app/core/config/bottin/config.json.tpl b/cluster/staging/app/core/config/bottin/config.json.tpl new file mode 100644 index 0000000..844f7b7 --- /dev/null +++ b/cluster/staging/app/core/config/bottin/config.json.tpl @@ -0,0 +1,26 @@ +{ + "suffix": "{{ key "secrets/directory/ldap_base_dn" }}", + "bind": "0.0.0.0:389", + "log_level": "debug", + "acl": [ + "*,{{ key "secrets/directory/ldap_base_dn" }}::read:*:* !userpassword !user_secret !alternate_user_secrets !garage_s3_secret_key", + "*::read modify:SELF:*", + "ANONYMOUS::bind:*,ou=users,{{ key "secrets/directory/ldap_base_dn" }}:", + "ANONYMOUS::bind:cn=admin,{{ key "secrets/directory/ldap_base_dn" }}:", + "*,ou=services,ou=users,{{ key "secrets/directory/ldap_base_dn" }}::bind:*,ou=users,{{ key "secrets/directory/ldap_base_dn" }}:*", + "*,ou=services,ou=users,{{ key "secrets/directory/ldap_base_dn" }}::read:*:*", + + "*:cn=asso_deuxfleurs,ou=groups,{{ key "secrets/directory/ldap_base_dn" }}:add:*,ou=invitations,{{ key "secrets/directory/ldap_base_dn" }}:*", + "ANONYMOUS::bind:*,ou=invitations,{{ key "secrets/directory/ldap_base_dn" }}:", + "*,ou=invitations,{{ key "secrets/directory/ldap_base_dn" }}::delete:SELF:*", + + "*:cn=asso_deuxfleurs,ou=groups,{{ key "secrets/directory/ldap_base_dn" }}:add:*,ou=users,{{ key "secrets/directory/ldap_base_dn" }}:*", + "*,ou=invitations,{{ key "secrets/directory/ldap_base_dn" }}::add:*,ou=users,{{ key "secrets/directory/ldap_base_dn" }}:*", + + "*:cn=asso_deuxfleurs,ou=groups,{{ key "secrets/directory/ldap_base_dn" }}:modifyAdd:cn=email,ou=groups,{{ key "secrets/directory/ldap_base_dn" }}:*", + "*,ou=invitations,{{ key "secrets/directory/ldap_base_dn" }}::modifyAdd:cn=email,ou=groups,{{ key "secrets/directory/ldap_base_dn" }}:*", + + "cn=admin,{{ key "secrets/directory/ldap_base_dn" }}::read add modify delete:*:*", + "*:cn=admin,ou=groups,{{ key "secrets/directory/ldap_base_dn" }}:read add modify delete:*:*" + ] +} diff --git a/cluster/staging/app/core/deploy/bottin.hcl b/cluster/staging/app/core/deploy/bottin.hcl new file mode 100644 index 0000000..1481fa8 --- /dev/null +++ b/cluster/staging/app/core/deploy/bottin.hcl @@ -0,0 +1,100 @@ +job "core-bottin" { + datacenters = ["neptune", "jupiter", "corrin", "bespin"] + type = "system" + priority = 90 + + update { + max_parallel = 1 + stagger = "1m" + } + + group "bottin" { + constraint { + distinct_property = "${meta.site}" + value = "1" + } + + network { + port "ldap_port" { + static = 389 + to = 389 + } + } + + task "bottin" { + driver = "docker" + config { + image = "dxflrs/bottin:7h18i30cckckaahv87d3c86pn4a7q41z" + network_mode = "host" + readonly_rootfs = true + ports = [ "ldap_port" ] + volumes = [ + "secrets/config.json:/config.json", + "secrets:/etc/bottin", + ] + } + + restart { + interval = "5m" + attempts = 10 + delay = "15s" + mode = "delay" + } + + resources { + memory = 100 + memory_max = 200 + } + + template { + data = file("../config/bottin/config.json.tpl") + destination = "secrets/config.json" + } + + template { + data = "{{ key \"secrets/consul/consul.crt\" }}" + destination = "secrets/consul.crt" + } + + template { + data = "{{ key \"secrets/consul/consul-client.crt\" }}" + destination = "secrets/consul-client.crt" + } + + template { + data = "{{ key \"secrets/consul/consul-client.key\" }}" + destination = "secrets/consul-client.key" + } + + template { + data = <