Mercurial > code > home > repos > infra
changeset 81:bf1573dd1947
dns fixes
author | drewp@bigasterisk.com |
---|---|
date | Sun, 26 Jun 2022 01:40:48 -0700 |
parents | bc909bf8b80e |
children | ff60853d7152 |
files | dns.py dns_check.py dns_k8s_check.py k8s_lookup/Dockerfile |
diffstat | 4 files changed, 18 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/dns.py Sat Jun 18 13:42:10 2022 -0700 +++ b/dns.py Sun Jun 26 01:40:48 2022 -0700 @@ -27,19 +27,18 @@ dhcp_hosts.flush() return dhcp_hosts - -#files.link('/etc/resolv.conf', '/run/systemd/resolve/stub-resolv.conf') - -# files.file(path='/etc/resolv.conf', present=False) -# files.link(path='/etc/resolv.conf', present=False) # bug -# server.shell(["rm -f /etc/resolv.conf"]) # broken fix -files.template(src='templates/resolv.conf.j2', - dest='/etc/resolv.conf', - # review this- it's probably a bad dep on bang. maybe both 10.5.0.1 and a public ns would be ok - ns='10.5.0.1' if host.name in ['prime', 'plus'] else '10.2.0.1', - force=True) +def resolv_conf_use_systemd_networkd(): + files.link(path='/etc/resolv.conf', target='/run/systemd/resolve/resolv.conf', force=True) +def resolv_conf_static_file(): + files.file(path='/etc/resolv.conf', present=False, force=True) + files.template(src='templates/resolv.conf.j2', + dest='/etc/resolv.conf', + # review this- it's probably a bad dep on bang. maybe both 10.5.0.1 and a public ns would be ok + ns='10.5.0.1' if host.name in ['prime', 'plus'] else '10.2.0.1', + force=True) if host.name == 'bang': + resolv_conf_static_file() apt.packages(packages=['dnsmasq']) systemd.service(service='dnsmasq', enabled=False, running=False) files.directory(path='/opt/dnsmasq') @@ -65,6 +64,7 @@ 'prime', 'pipe' ]: + resolv_conf_use_systemd_networkd() files.template(src='templates/hosts.j2', dest='/etc/hosts') files.template(src='templates/resolved.conf.j2', dest='/etc/systemd/resolved.conf') systemd.service(service='systemd-resolved.service', running=True, restarted=True)
--- a/dns_check.py Sat Jun 18 13:42:10 2022 -0700 +++ b/dns_check.py Sun Jun 26 01:40:48 2022 -0700 @@ -1,9 +1,8 @@ # run key dns lookups everywhere import tempfile -import requests from pyinfra import host -from pyinfra.operations import apt, files, server, systemd +from pyinfra.operations import server def check(name, addr): @@ -29,7 +28,6 @@ projects.bigasterisk.com etc -(or another idea: wireguard everywhere all the time) ''' if host.name in ['dash', 'bang', 'slash']: @@ -47,7 +45,7 @@ check('slash', '10.5.0.6') else: check('bang', '10.2.0.1') - check('slash', '10.2.0.127') + check('slash', '10.2.0.145') check('bang5', '10.5.0.1') check('prime', '10.5.0.2')
--- a/dns_k8s_check.py Sat Jun 18 13:42:10 2022 -0700 +++ b/dns_k8s_check.py Sun Jun 26 01:40:48 2022 -0700 @@ -24,10 +24,10 @@ r = subprocess.run( ['kubectl', 'exec', f'pod/{podName}'] + ['--'] + # - ['dnsget', '-q', lookupName], + ['dnsget', '-o', 'timeout:2', '-q', lookupName], capture_output=True) result = (r.stdout + r.stderr).decode('ascii').strip().replace('\n', '; ') print(f'looked up {lookupName} from pod on {runningOn} -> {result}') finally: - subprocess.check_call(["skaffold", "delete"], cwd="/my/proj/infra/k8s_lookup/") \ No newline at end of file + pass#subprocess.check_call(["skaffold", "delete"], cwd="/my/proj/infra/k8s_lookup/") \ No newline at end of file
--- a/k8s_lookup/Dockerfile Sat Jun 18 13:42:10 2022 -0700 +++ b/k8s_lookup/Dockerfile Sun Jun 26 01:40:48 2022 -0700 @@ -1,4 +1,4 @@ FROM ubuntu:jammy-20220428 -RUN echo 2022-05-04 && apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y udns-utils -CMD ["sleep", "1d"] \ No newline at end of file +RUN echo 2022-06-20 && apt-get update +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y udns-utils oping curl +CMD ["sleep", "1d"]