comparison dns.py @ 70:136d86d06ce6

dns improvements
author drewp@bigasterisk.com
date Sat, 11 Jun 2022 22:53:23 -0700
parents 49a69852a4f4
children 3f7d4626234c
comparison
equal deleted inserted replaced
69:659e4b228909 70:136d86d06ce6
26 dhcp_hosts.write(f'{row["mac"]},{row["hostname"]},{row["ip"]},24h\n') 26 dhcp_hosts.write(f'{row["mac"]},{row["hostname"]},{row["ip"]},24h\n')
27 dhcp_hosts.flush() 27 dhcp_hosts.flush()
28 return dhcp_hosts 28 return dhcp_hosts
29 29
30 30
31 #files.link('/etc/resolv.conf', '/run/systemd/resolve/stub-resolv.conf')
32
33 # files.file(path='/etc/resolv.conf', present=False)
34 # files.link(path='/etc/resolv.conf', present=False) # bug
35 # server.shell(["rm -f /etc/resolv.conf"]) # broken fix
36 files.template(src='templates/resolv.conf.j2',
37 dest='/etc/resolv.conf',
38 # review this- it's probably a bad dep on bang. maybe both 10.5.0.1 and a public ns would be ok
39 ns='10.5.0.1' if host.name in ['prime', 'plus'] else '10.2.0.1',
40 force=True)
41
31 if host.name == 'bang': 42 if host.name == 'bang':
32 apt.packages(packages=['dnsmasq']) 43 apt.packages(packages=['dnsmasq'])
33 systemd.service(service='dnsmasq', enabled=False, running=False) 44 systemd.service(service='dnsmasq', enabled=False, running=False)
34 files.directory(path='/opt/dnsmasq') 45 files.directory(path='/opt/dnsmasq')
35 46
44 files.template(src='templates/dnsmasq/dnsmasq.service.j2', 55 files.template(src='templates/dnsmasq/dnsmasq.service.j2',
45 dest=f'/etc/systemd/system/dnsmasq_{net_name}.service', 56 dest=f'/etc/systemd/system/dnsmasq_{net_name}.service',
46 net=net_name) 57 net=net_name)
47 systemd.service(service=f'dnsmasq_{net_name}', enabled=True, restarted=True, daemon_reload=True) 58 systemd.service(service=f'dnsmasq_{net_name}', enabled=True, restarted=True, daemon_reload=True)
48 59
49 files.link('/etc/resolv.conf', '/run/systemd/resolve/stub-resolv.conf')
50
51 if host.name in [ 60 if host.name in [
52 'garage', 61 'garage',
53 'dash', 62 'dash',
54 'slash', 63 'slash',
55 'frontbed', 64 'frontbed',
56 'prime', 65 'prime',
66 'pipe'
57 ]: 67 ]:
58 files.template(src='templates/hosts.j2', dest='/etc/hosts') 68 files.template(src='templates/hosts.j2', dest='/etc/hosts')
59
60 files.link(path='/etc/resolv.conf', target='/run/systemd/resolve/resolv.conf')
61 files.template(src='templates/resolved.conf.j2', dest='/etc/systemd/resolved.conf') 69 files.template(src='templates/resolved.conf.j2', dest='/etc/systemd/resolved.conf')
62
63 systemd.service(service='systemd-resolved.service', running=True, restarted=True) 70 systemd.service(service='systemd-resolved.service', running=True, restarted=True)