Mercurial > code > home > repos > infra
comparison dns.py @ 34:d4fb38f13c79
refactor dns and some other non-net setup
author | drewp@bigasterisk.com |
---|---|
date | Sat, 15 Jan 2022 15:40:22 -0800 |
parents | |
children | 4026b6b8028f |
comparison
equal
deleted
inserted
replaced
33:ea110b6766bd | 34:d4fb38f13c79 |
---|---|
1 from pyinfra import host | |
2 from pyinfra.operations import apt, files, server, systemd | |
3 | |
4 if host.name == 'bang': | |
5 apt.packages(packages=['dnsmasq']) | |
6 systemd.service(service='dnsmasq', enabled=False, running=False) | |
7 files.directory(path='/opt/dnsmasq') | |
8 | |
9 for net_name in ['10.1', '10.2', '10.5']: | |
10 files.directory(path=f'/opt/dnsmasq/{net_name}') | |
11 files.template(src='templates/dnsmasq/dnsmasq.conf.j2', dest=f'/opt/dnsmasq/{net_name}/dnsmasq.conf', net=net_name) | |
12 files.template(src='templates/dnsmasq/hosts.j2', dest=f'/opt/dnsmasq/{net_name}/hosts', net=net_name) | |
13 files.template(src='templates/dnsmasq/dhcp_hosts.j2', dest=f'/opt/dnsmasq/{net_name}/dhcp_hosts', net=net_name) | |
14 | |
15 files.template(src='templates/dnsmasq/dnsmasq.service.j2', | |
16 dest=f'/etc/systemd/system/dnsmasq_{net_name}.service', | |
17 net=net_name) | |
18 systemd.service(service=f'dnsmasq_{net_name}', restarted=True, daemon_reload=True) | |
19 | |
20 if host.name in [ | |
21 'garage', | |
22 'dash', | |
23 'slash', | |
24 'frontbed', | |
25 'prime', | |
26 ]: | |
27 files.template(src='templates/hosts.j2', dest='/etc/hosts') | |
28 | |
29 files.link(path='/etc/resolv.conf', target='/run/systemd/resolve/resolv.conf') | |
30 files.template(src='templates/resolved.conf.j2', dest='/etc/systemd/resolved.conf') | |
31 | |
32 systemd.service(service='systemd-resolved.service', running=True, restarted=True) |