blob: 8b4f47039b38502bfa39ad682c02b471d165851e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# Ansible playbook for installing a Puomi Internet router.
- hosts: image
tasks:
- name: "unset root password so that virtual console logins work"
shell: |
sed -i '/^root:[^:]*:/s//root::/' /etc/passwd /etc/shadow
# Install software we'll need for router functionality.
- name: "add contrib and non-free to APT sources, for firmware"
apt_repository:
repo: |
deb http://deb.debian.org/debian {{ hostvars[inventory_hostname]["ansible_distribution_release"] }} contrib non-free
update_cache: no
- name: "update apt lists"
shell: |
set -xeu
ls -la /etc
rm /etc/resolv.conf
echo nameserver 8.8.8.8 > /etc/resolv.conf
apt-get update
echo update done
- name: "install software"
apt:
name:
- bind9-dnsutils
- bridge-utils
- dnsmasq
# Network configuration.
- name: "configure bridge device br0 for local network ports"
copy:
content: |
[NetDev]
Name=br0
Kind=bridge
dest: /etc/systemd/network/br0.netdev
- name: "add local network ports to br0"
copy:
content: |
[Match]
Name=eth[^0]*
[Network]
Bridge=br0
dest: /etc/systemd/network/local.network
- name: "configure bridge br0"
copy:
content: |
[Match]
Name=br0
[Network]
Address={{ puomi_lan_ip }}/24
DHCPServer=false
IPForward=true
IPMasquerade=true
ConfigureWithoutCarrier=true
dest: /etc/systemd/network/br0.network
- name: "configure dnsmasq for configuration .d directory support"
lineinfile:
path: /etc/dnsmasq.conf
regexp: ^conf-dir
line: "conf-dir=/etc/dnsmasq.d/,*.conf"
- name: "configure dnsmasq for local bridge br0"
copy:
content: |
dhcp-range={{ puomi_dhcp_start }},{{ puomi_dhcp_end }},{{ puomi_dhcp_netmask }},{{ puomi_dhcp_lease }}
host-record={{ hostname }},{{ puomi_lan_ip }}
interface=br0
max-cache-ttl=30
neg-ttl=10
dest: /etc/dnsmasq.d/router.conf
vars:
ansible_python_interpreter: /usr/bin/python3
puomi_lan_ip: 10.1.1.1
puomi_dhcp_start: 10.1.1.10
puomi_dhcp_end: 10.1.1.250
puomi_dhcp_netmask: 255.255.255.0
puomi_dhcp_lease: 1h
|