From 4e9155e0dbd318563d22d1faf3d120dc4c0483c5 Mon Sep 17 00:00:00 2001 From: vincent Date: Sat, 4 Nov 2023 21:33:51 +0100 Subject: [PATCH] prepare DNS migration --- ansible/group_vars/database/database | 4 + ansible/group_vars/database/vault_database | 81 +++++---- docs/ADR/004-DNS.md | 2 +- nomad-job/pdns-auth.nomad | 162 ++++++++++++++++++ .../cloud}/.terraform.lock.hcl | 0 {infra => terraform/cloud}/dns.tf | 64 ------- {infra => terraform/cloud}/firewall.tf | 0 {infra => terraform/cloud}/output.tf | 0 {infra => terraform/cloud}/providers.tf | 0 {infra => terraform/cloud}/server.tf | 0 {infra => terraform/cloud}/ssh.tf | 0 {infra => terraform/cloud}/variable.tf | 2 +- terraform/dns/.terraform.lock.hcl | 56 ++++++ terraform/dns/CnameReverse.tf | 17 ++ terraform/dns/main.tf | 25 +++ terraform/dns/makefile | 12 ++ terraform/dns/records.tf | 115 +++++++++++++ terraform/dns/variable.tf | 47 +++++ terraform/dns/zone.tf | 20 +++ terraform/exportTFsecret.sh | 3 + .../vault}/.terraform.lock.hcl | 0 {vault => terraform/vault}/drone-vault.tf | 0 {vault => terraform/vault}/ldap.tf | 0 {vault => terraform/vault}/main.tf | 0 {vault => terraform/vault}/migrateBackend.hcl | 0 {vault => terraform/vault}/nomad.tf | 4 +- {vault => terraform/vault}/policy.tf | 0 .../vault}/standalone_vault.sh | 0 {vault => terraform/vault}/variable.tf | 0 {vault => terraform/vault}/vault-snapshot.tf | 0 30 files changed, 510 insertions(+), 104 deletions(-) create mode 100644 nomad-job/pdns-auth.nomad rename {infra => terraform/cloud}/.terraform.lock.hcl (100%) rename {infra => terraform/cloud}/dns.tf (69%) rename {infra => terraform/cloud}/firewall.tf (100%) rename {infra => terraform/cloud}/output.tf (100%) rename {infra => terraform/cloud}/providers.tf (100%) rename {infra => terraform/cloud}/server.tf (100%) rename {infra => terraform/cloud}/ssh.tf (100%) rename {infra => terraform/cloud}/variable.tf (94%) create mode 100644 terraform/dns/.terraform.lock.hcl create mode 100644 terraform/dns/CnameReverse.tf create mode 100644 terraform/dns/main.tf create mode 100644 terraform/dns/makefile create mode 100644 terraform/dns/records.tf create mode 100644 terraform/dns/variable.tf create mode 100644 terraform/dns/zone.tf create mode 100755 terraform/exportTFsecret.sh rename {vault => terraform/vault}/.terraform.lock.hcl (100%) rename {vault => terraform/vault}/drone-vault.tf (100%) rename {vault => terraform/vault}/ldap.tf (100%) rename {vault => terraform/vault}/main.tf (100%) rename {vault => terraform/vault}/migrateBackend.hcl (100%) rename {vault => terraform/vault}/nomad.tf (96%) rename {vault => terraform/vault}/policy.tf (100%) rename {vault => terraform/vault}/standalone_vault.sh (100%) rename {vault => terraform/vault}/variable.tf (100%) rename {vault => terraform/vault}/vault-snapshot.tf (100%) diff --git a/ansible/group_vars/database/database b/ansible/group_vars/database/database index 74b49ca..9c809b5 100644 --- a/ansible/group_vars/database/database +++ b/ansible/group_vars/database/database @@ -18,6 +18,10 @@ postgresql_databases: owner: vikunja - name: ghostfolio owner: ghostfolio + - name: pdns-auth + owner: pdns-auth + - name: pdns-admin + owner: pdns-admin postgres_consul_service: true postgres_consul_service_name: db diff --git a/ansible/group_vars/database/vault_database b/ansible/group_vars/database/vault_database index af70022..49c917f 100644 --- a/ansible/group_vars/database/vault_database +++ b/ansible/group_vars/database/vault_database @@ -1,38 +1,45 @@ $ANSIBLE_VAULT;1.1;AES256 -31336239306162353439323635633133393530396161656139303031323330366431653665623032 -3133326132353635336331353236396334623736383461310a633931616636396665363931393432 -34663535363362363030323439646134653163656538306230323739653739316464363232623264 -3638643737316132640a316461316335336432383066356134356231323964383861313465373765 -39393536636531663136346461383530343233346233613562336633353934353861313135643239 -36303930363663633936626361623835633932633863653230313532336239653931303530623536 -36626631363662346661313664303866343165303337376131656663373266383261643331386263 -64333137653134613365383538646463653336663637623163666365646439383636376238643131 -35373965326561666238656363333266633262373431653837623562633436386132376239363461 -37376631336265326137626138653063353766346264663632366266636635313364303432363731 -32323938386430653238303834636465333865383962623066356430396531353463393133653730 -33383364373130366437393938616431646536623635356464356438323664383635363665323561 -65613463636633643033396232386437373532663338346437656562333536333863306538386563 -34326138646331663165323061336139323963666632626635643931363330316136353262306637 -65343432643136383136636335313038343963383937663865303430623466383465623332373764 -66366232646132653632366530643362323131616333333534616264326136636363386138623463 -61323562303261363331653363326137313966323563373331356362373431313735613937313239 -30373130336637623766393130646330366235373831336538376364376139396362326336396238 -33353234323036333631343137323130303531616133363630633336633434363932386334333964 -66396632616433643637306564656431663531353762356534663866613765376631356566626164 -62646262616265313533666362653837373230303863313336656566623036396530346561313937 -66376662353361653532616637666439653565383737636239396233613435373330653664323931 -61333434346430623637653232363462336330386538646433303830373235333539326433333261 -32306634396531626638366465646364393330653739393764623639396565653234376634366535 -36303361613662353337333162343633313437316431336332646235636332653239366338623737 -35643262316531623538626335343563636238363639373730333332393032396565643735383236 -61383437336237363934626535343037353036343532646339393937316535623532633838373964 -61633932626664353264653535373130346334626262373665666137663366663738656563393966 -62313939643930353165356430363031613830383738333938386635333234636630313735613266 -62373862306335383839656566386163333530626539353436623031303432643461623663303036 -66313064323363623438316532386331313762343266323430303066643861653261363765623038 -38613334356431323033653733363835616534316233383431303136623761333935343231626430 -38353237333430633063303264653033316539353862336433366661303538653933373437346161 -34313164346332336637653563336631313762333031333237326265663437666539306332396136 -36323736313562636235353139663532333436363163383238643531336131386664636530336239 -38336539363661333330643238326263333730663035313534643039376237313332363638663863 -32643334343034333438383132666134386562643566643463346561313036363837 +64656332666561346439636331396439333566646361333031613764376634363061623635356630 +3832326235316435316264653637396130383465323234630a653138393161316232323236323366 +32363661633631623132323864663366633766396266623630636135396165663062353434613231 +6363646665626439610a313233313639333232393035633139326561316431393837616231313933 +38646532613665666136316635376533653161616630313532333330393364636662653331336637 +39353462336130333933383033656634633461333461393730633333343330306432623466623062 +32353962623338356630393935646537313335313335323464666265303732653633396332363965 +36356338386330653863646134623234623230356232643535643763303162626132333530626639 +39316166613862356264336362303833343236616635613136356433663766383861333832656261 +35613662653266396461383162303230613865373232353437646131633063633634346633383563 +31323736303537643433633235613464376230373332613331623439643462313362356437623463 +65326335653938626461353332356434303962376630626666666631386334316261653639623633 +34326633393330313064326562363838316366316361626662393435363262333264626333396136 +66353936623763323865656632373763303365316131663064343830663330323566346535316436 +63623931383461363364613632363661613734306535373536643236656161393634633435653862 +34316666353234646633633635653934373335396635343035663238323636323662346632303865 +35326333366439646661303437626238326435313032373031636535353963666263636635366234 +36336562633666623932653465376237366232306262386565646631346432346631353566326535 +32356337333762653161376439353035323633363833633862336134366132623963326231643461 +35623863373730313935393631626266336465613261636364353533666233613831323031643035 +32663630316264633932643132633061303438613339646264666334306630643038323632366330 +31366365333039636434613537386436313539396632613766333136663638393462653263613165 +33323937313031626233623237616464323939303131613465326362346632346538323161343362 +65353839386133326233356561363864336261663135343865323861623330613736333835396261 +64653361333530326630363633383836396565646463396239616261646635303535316135306537 +64343830616566663633323531383464383834373539646637633465616533383238346565303337 +34386561626266303833353665306335326264343533386263626562373633303135313735643733 +37333766373465326133663663303166316134643732343938343930616631383137356137373564 +31633831663264653762326534343635323364313632353661323330646638363062346137646337 +61323334623434613333613038633637666131393338653839373835633062396661653537343138 +61643961623366393735393438356461333731326265313937613066323038313163353835363135 +33323932353264313536393865373232333930613636343661613033656165616237373439383531 +38393932366633616639303964386333386462353935646432663330313137306465386634633931 +33656533306665653836363830363164303039356463386130663536636330396138643363383838 +35393966646630663535623836303262353739353063303763333530383630353838623939376535 +34343239373831623232343530396561393730303066323236306539333263656133366363396534 +30666662336435313561666536643231633562663037353837303936326164353366333032656431 +39303063343536336431336637323239356432616562656565306561666664663930303232313464 +34333236613239656562323037656137376135396636323361383565336636303338663138396238 +65396130303931393266636630656637333464346361303763653931383464326365333232623437 +61623263316562643636386637303531626238333131656130306236636230626362653935353331 +34366663303235653431616135343963643935303336313231343562376430343564393832343335 +36363130313533373137383738346438666634303537633232636535303835636333653636303937 +39356339656234303432 diff --git a/docs/ADR/004-DNS.md b/docs/ADR/004-DNS.md index 9c5bf44..0a739cb 100644 --- a/docs/ADR/004-DNS.md +++ b/docs/ADR/004-DNS.md @@ -68,7 +68,7 @@ we have curently three authority domain on NAS: we could migrate authority DNS in cluster ducamps.win and ducamps.eu are only use for application access so no dependence with cluster build -need to study cluster build dependance for lan.ducamps.eu +need to study cluster build dependance for lan.ducamps.eu-> in every case in case of build from scratch need to use IP need keepalive IP and check if no conflict if store on same machine than pihole->ok don't need to listen on 53 only request by recursor DNS authority will dependant to storage (less problematic than recursor) diff --git a/nomad-job/pdns-auth.nomad b/nomad-job/pdns-auth.nomad new file mode 100644 index 0000000..16267a0 --- /dev/null +++ b/nomad-job/pdns-auth.nomad @@ -0,0 +1,162 @@ + +job "pdns-auth" { + datacenters = ["homelab"] + priority = 100 + meta { + force = 2 + } + type = "service" + constraint { + attribute = "${attr.cpu.arch}" + value = "amd64" + } + group "pdns-auth" { + network { + port "dns" { + static=5300 + } + port "http" { + static = 8081 + } + port "pdnsadmin"{ + to = 80 + } + } + vault { + policies = ["pdns"] + } + task "pdns-auth" { + + driver = "docker" + service { + name = "pdns-auth" + port = "dns" + + check { + name = "service: dns tcp check" + type = "tcp" + interval = "10s" + timeout = "2s" + + success_before_passing = "3" + failures_before_critical = "3" + } + } + config { + image = "powerdns/pdns-auth-48:latest" + network_mode = "host" + + volumes = [ + "/mnt/diskstation/nomad/pdns-auth/var:/var/lib/powerdns/", + "local/dnsupdate.conf:/etc/powerdns/pdns.d/dnsupdate.conf", + "local/pdns.conf:/etc/powerdns/pdns.conf" + ] + } + template { + destination = "secrets/env" + + data = <