Mercurial > code > home > repos > infra
diff dns.py @ 282:e10ee3ddadcf
pi changes
author | drewp@bigasterisk.com |
---|---|
date | Mon, 15 Apr 2024 02:27:07 -0700 |
parents | 5c5c314051c5 |
children | 3af02e24eaf9 |
line wrap: on
line diff
--- a/dns.py Mon Apr 15 00:04:41 2024 -0700 +++ b/dns.py Mon Apr 15 02:27:07 2024 -0700 @@ -7,6 +7,7 @@ is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] + def dnsmasq_instance(net_name, house_iface, dhcp_range='10.2.0.10,10.2.0.11', @@ -25,7 +26,7 @@ router=listen_address, ) files.template(src='templates/dnsmasq/hosts.j2', dest=f'/opt/dnsmasq/{net_name}/hosts', net=net_name) - + dhcp_hosts = subprocess.check_output(['python3', '/my/serv/lanscape/src/public/make_dhcp_hosts.py'], encoding='utf8') files.put(src=StringIO(dhcp_hosts), dest=f'/opt/dnsmasq/{net_name}/dhcp_hosts') @@ -39,7 +40,8 @@ def standard_host_dns(): files.template(src='templates/hosts.j2', dest='/etc/hosts') if is_pi: - files.put(dest='/etc/resolv.conf', src=StringIO(''' + files.put(dest='/etc/resolv.conf', + src=StringIO(''' # written by pyinfra nameserver 10.2.0.3 search bigasterisk.com @@ -50,26 +52,34 @@ systemd.service(service='systemd-resolved.service', running=True, restarted=True) +pi_serial_hostname = [ +] + + def rpi_net_boot(): files.directory(path='/opt/dnsmasq/tftp') for pi_serial, _ in pi_serial_hostname: files.directory(path=f'/opt/dnsmasq/tftp/{pi_serial}') # then we transfer from pi to here + def rpi_iscsi_volumes(): iscsi_dir = '/d2/rpi-iscsi' for _, pi_hostname in pi_serial_hostname: - out= f'{iscsi_dir}/{pi_hostname}.disk' + out = f'{iscsi_dir}/{pi_hostname}.disk' files.directory(path=iscsi_dir) server.shell(f'dd if=/dev/zero of={out} count=0 bs=1 seek=5G conv=excl || true') - files.put(dest=f"/etc/tgt/conf.d/{pi_hostname}.conf", src=StringIO(f""" + files.put(dest=f"/etc/tgt/conf.d/{pi_hostname}.conf", + src=StringIO(f""" <target iqn.2024-03.com.bigasterisk:{pi_hostname}.target> backing-store {out} initiator-name iqn.2024-03.com.bigasterisk:{pi_hostname}.initiator </target> """)) - systemd.service(service='tgt.service', running=True, restarted=True) - + # restarting is disruptive to connected pis, and they might need to be + # visited: + #systemd.service(service='tgt.service', running=True, restarted=True) + standard_host_dns() @@ -82,7 +92,7 @@ dnsmasq_instance('10.5', house_iface='unused', dhcp_range='unused', listen_address='unused') # only works after wireguard is up elif host.name == 'ditto': - rpi_iscsi_volumes() # move out of this file- it's not dns + rpi_iscsi_volumes() # move out of this file- it's not dns elif host.name == 'pipe': rpi_net_boot() files.directory(path='/opt/dnsmasq')