Mercurial > code > home > repos > infra
changeset 15:516a91a3ec08
closer to working netplan
author | drewp@bigasterisk.com |
---|---|
date | Sat, 13 Nov 2021 12:13:54 -0800 |
parents | ac4d24d01b68 |
children | c5784e3d4f8d |
files | inventory.py net.py |
diffstat | 2 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/inventory.py Sat Nov 13 12:13:39 2021 -0800 +++ b/inventory.py Sat Nov 13 12:13:54 2021 -0800 @@ -3,36 +3,45 @@ big = [ ('bang', { - 'wireguard_address': '10.5.0.1' + 'wireguard_address': '10.5.0.1', }), ('dash', { + 'ssh_hostname': '10.1.0.5', 'interface': 'enp2s0', 'addr': '10.1.0.5', - 'wireguard_address': '10.5.0.5' + 'wireguard_address': '10.5.0.5', }), ('slash', { + 'ssh_hostname': '10.1.0.6', 'interface': 'enp3s0', 'addr': '10.1.0.6', - 'wireguard_address': '10.5.0.6' + 'wireguard_address': '10.5.0.6', }), + ('dot', { + 'ssh_hostname': '10.2.0.49', + 'interface': 'enp3s0', + 'addr': '10.2.0.30', + 'wireguard_address': '10.5.0.30', + }) ] pi = [ ('frontbed', { + 'ssh_hostname': '10.2.0.17', 'interface': 'eth0', 'addr': '10.2.0.17', - 'wireguard_address': '10.5.0.17' + 'wireguard_address': '10.5.0.17', }), ('garage', { 'ssh_hostname': '10.2.0.19', 'interface': 'eth0', 'addr': '10.2.0.14', - 'wireguard_address': '10.5.0.14' + 'wireguard_address': '10.5.0.14', }), ] remote = [ ('prime', { 'ssh_hostname': 'public.bigasterisk.com', - 'wireguard_address': '10.5.0.2' + 'wireguard_address': '10.5.0.2', }), ]
--- a/net.py Sat Nov 13 12:13:39 2021 -0800 +++ b/net.py Sat Nov 13 12:13:54 2021 -0800 @@ -9,6 +9,7 @@ ssh_host = host.host_data.get('ssh_hostname', host.name) if is_wifi: + # todo: netplan could do this, below files.put(src="secrets/wpa_supplicant.conf", dest="/etc/wpa_supplicant/wpa_supplicant.conf") files.template(src='templates/hosts.j2', dest='/etc/hosts') @@ -30,15 +31,22 @@ ns = '10.1.0.1' files.template(src='templates/resolv.conf.j2', dest='/etc/resolv.conf', ns=ns) -if host.name in ['dash', 'slash', 'garage', 'frontbed']: +if host.name in ['dash', 'slash', 'garage', 'frontbed', 'dot']: # might need to upgrade pi systemd if there are errors in this part apt.packages(packages=['netplan.io']) - files.file(path='/etc/netplan/00-installer-config.yaml', present=False) + for bad in [ + '01-netcfg.yaml', + '01-network-manager-all.yaml', + '00-installer-config.yaml', + '99-ansible-written.yaml', + '99-dns.conf', + ]: + files.file(path=f'/etc/netplan/{bad}', present=False) addrs = host.get_fact(Ipv4Addrs) ipv4Interface = host.host_data['interface'] ipv4Address = host.host_data['addr'] files.template(src='templates/netplan.yaml.j2', - dest='/etc/netplan/99-ansible-written.yaml', + dest='/etc/netplan/99-pyinfra-written.yaml', ipv4Interface=ipv4Interface, ipv4Address=ipv4Address) server.shell(commands=['netplan apply'])