comparison dns.py @ 81:bf1573dd1947

dns fixes
author drewp@bigasterisk.com
date Sun, 26 Jun 2022 01:40:48 -0700
parents 3f7d4626234c
children dae714e8f620
comparison
equal deleted inserted replaced
80:bc909bf8b80e 81:bf1573dd1947
25 for row in lanscape_config['dhcp_table']: 25 for row in lanscape_config['dhcp_table']:
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 def resolv_conf_use_systemd_networkd():
31 #files.link('/etc/resolv.conf', '/run/systemd/resolve/stub-resolv.conf') 31 files.link(path='/etc/resolv.conf', target='/run/systemd/resolve/resolv.conf', force=True)
32 32 def resolv_conf_static_file():
33 # files.file(path='/etc/resolv.conf', present=False) 33 files.file(path='/etc/resolv.conf', present=False, force=True)
34 # files.link(path='/etc/resolv.conf', present=False) # bug 34 files.template(src='templates/resolv.conf.j2',
35 # server.shell(["rm -f /etc/resolv.conf"]) # broken fix 35 dest='/etc/resolv.conf',
36 files.template(src='templates/resolv.conf.j2', 36 # review this- it's probably a bad dep on bang. maybe both 10.5.0.1 and a public ns would be ok
37 dest='/etc/resolv.conf', 37 ns='10.5.0.1' if host.name in ['prime', 'plus'] else '10.2.0.1',
38 # review this- it's probably a bad dep on bang. maybe both 10.5.0.1 and a public ns would be ok 38 force=True)
39 ns='10.5.0.1' if host.name in ['prime', 'plus'] else '10.2.0.1',
40 force=True)
41 39
42 if host.name == 'bang': 40 if host.name == 'bang':
41 resolv_conf_static_file()
43 apt.packages(packages=['dnsmasq']) 42 apt.packages(packages=['dnsmasq'])
44 systemd.service(service='dnsmasq', enabled=False, running=False) 43 systemd.service(service='dnsmasq', enabled=False, running=False)
45 files.directory(path='/opt/dnsmasq') 44 files.directory(path='/opt/dnsmasq')
46 45
47 dhcp_hosts = prepare_dhcp_hosts() 46 dhcp_hosts = prepare_dhcp_hosts()
63 'slash', 62 'slash',
64 'frontbed', 63 'frontbed',
65 'prime', 64 'prime',
66 'pipe' 65 'pipe'
67 ]: 66 ]:
67 resolv_conf_use_systemd_networkd()
68 files.template(src='templates/hosts.j2', dest='/etc/hosts') 68 files.template(src='templates/hosts.j2', dest='/etc/hosts')
69 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')
70 systemd.service(service='systemd-resolved.service', running=True, restarted=True) 70 systemd.service(service='systemd-resolved.service', running=True, restarted=True)