Move network to separate ansible repository

This commit is contained in:
Przemek Grondek 2023-12-15 00:41:42 +01:00
parent 3fa34c3993
commit 5c17fcbd2d
8 changed files with 0 additions and 357 deletions

View File

@ -33,9 +33,6 @@
- duplicity
- node_explorer
- hosts: node-01.lan
roles:
- network
- hosts: laptop.lan
roles:

View File

@ -1,17 +0,0 @@
---
- name: create directory
file:
path: /srv/dhcp/config
state: directory
- name: Create dhcpd.conf
become: yes
template:
src: etc/dhcpd/dhcpd.conf.j2
dest: /srv/dhcp/config/dhcpd.conf
vars:
network: "{{ lan }}"
- name: restart container
shell:
cmd: docker service update --force --detach dhcp

View File

@ -1,41 +0,0 @@
---
- name: create dns directory
file:
path: /srv/bind/config
state: directory
- name: Create db lan
template:
src: etc/bind/db.lan.j2
dest: /srv/bind/config/db.lan
vars:
network: "{{ lan }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: Create reverse db lan
template:
src: etc/bind/db.reverse.j2
dest: /srv/bind/config/db.{{ lan.network_reverse }}
vars:
network: "{{ lan }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: Create db iot
template:
src: etc/bind/db.lan.j2
dest: /srv/bind/config/db.iot
vars:
network: "{{ iot }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: Create reverse db iot
template:
src: etc/bind/db.reverse.j2
dest: /srv/bind/config/db.{{ iot.network_reverse }}
vars:
network: "{{ iot }}"
serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02"
- name: restart container
shell:
cmd: docker service update --force --detach bind

View File

@ -1,6 +0,0 @@
---
- import_tasks: dns-file.yml
become: yes
- import_tasks: dhcp-file.yml
become: yes

View File

@ -1,17 +0,0 @@
$TTL 86400
$ORIGIN {{ network.network_name }}.
@ IN SOA {{ network.network_name }}. dns.{{ network.network_name }}. (
{{ serial }};
604800;
86400;
2419200;
86400;
)
@ IN NS dns.{{ network.network_name }}.
DNS IN A {{ network.dns }}
{% for host in network.hosts %}
{{ host.name }} IN A {{ network.network_prefix }}.{{ host.ip }}
{% endfor %}

View File

@ -1,15 +0,0 @@
$TTL 86400
$ORIGIN {{ network.network_reverse }}.IN-ADDR.ARPA.
@ IN SOA {{ network.network_name }}. dns.{{ network.network_name }}. (
{{ serial }} ; serial number
604800 ; refresh
86400 ; update retry
2419200 ; expiry
86400 ; Negative caching TTL
)
@ IN NS dns.{{ network.network_name }}.
{% for host in network.hosts %}
{{ host.ip }} IN PTR {{ host.name }}.{{ network.network_name }}.
{% endfor %}

View File

@ -1,21 +0,0 @@
ddns-update-style none;
authorative;
subnet {{ network.address }} netmask {{ network.mask }} {
option domain-name-servers {{ network.dns }};
option domain-name "{{ network.network_name }}";
option domain-search "lan", "iot";
option routers {{ network.gateway }};
default-lease-time 86400;
max-lease-time 86400;
{% if network.range_start is defined %}
range {{ network.range_start }} {{ network.range_end }};
{% endif %}
{% for host in network.hosts %}
host {{ host.name }} { hardware ethernet {{ host.mac }}; fixed-address {{ network.network_prefix }}.{{ host.ip }}; }
{% if host.mac2 is defined %}
host {{ host.name }}_2 { hardware ethernet {{ host.mac2 }}; fixed-address {{ network.network_prefix }}.{{ host.ip }}; }
{% endif %}
{% endfor %}
}

View File

@ -1,237 +0,0 @@
---
lan:
network_prefix: 192.168.50
network_reverse: 50.168.192
network_name: lan
address: 192.168.50.0
mask: 255.255.255.0
gateway: 192.168.50.2
dns: 192.168.50.100
range_start: 192.168.50.200
range_end: 192.168.50.250
hosts:
- name: router
ip: 2
mac: 2c:b0:5d:4a:72:62
- name: bender
ip: 3
mac: e0:3f:49:6f:03:c2
- name: prusa
ip: 6
mac: b8:27:eb:c3:a6:6a
- name: hulk
ip: 21
mac: 24:4b:fe:05:e2:8b
- name: banner
ip: 22
mac: '52:54:00:49:04:51'
- name: hawkeye
ip: 23
mac: b4:8c:9d:5e:a1:8b
mac2: a0:ce:c8:77:c3:13
- name: thor
ip: 24
mac: 5c:1b:f4:e4:52:11
mac2: 5c:1b:f4:e2:df:18
- name: steamdeck
ip: 30
mac: 2c:3b:70:aa:4a:7d
mac2: 10:82:86:2A:E7:0C
- name: android-sgs9
ip: 41
mac: fe:bd:3d:7b:3a:58
- name: ipad
ip: 42
mac: b8:63:4d:b6:4c:bc
- name: iphone
ip: 43
mac: 0c:19:f8:10:c2:b3
- name: apple-watch
ip: 44
mac: 9c:28:b3:24:bc:9c
- name: ipad-pro
ip: 45
mac: 38:88:a4:6e:95:a3
- name: node-01
ip: 101
mac: dc:a6:32:8b:7b:ab
- name: node-02
ip: 102
mac: dc:a6:32:3c:0f:ff
- name: node-03
ip: 103
mac: dc:a6:32:3c:1a:ec
- name: node-04
ip: 104
mac: d6:29:c5:7e:61:3e
- name: node-05
ip: 105
mac: d8:3a:dd:31:d7:dc
- name: uatu
ip: 106
mac: b8:27:eb:19:f8:0d
- name: pikvm
ip: 107
mac: d8:3a:dd:3f:07:02
iot:
network_prefix: 192.168.60
network_reverse: 60.168.192
network_name: iot
dns: 192.168.50.100
hosts:
- name: hue-light
ip: 3
mac: 00:17:88:27:38:8a
- name: harmony-hub
ip: 4
mac: c8:db:26:06:7e:f9
- name: airpurifier-bedroom
ip: 5
mac: 34:ce:00:a4:f6:75
- name: airpurifier-livingroom
ip: 6
mac: 50:ec:50:85:95:2d
- name: roborock
ip: 7
mac: 50:ec:50:0a:c3:94
- name: humidifier
ip: 8
mac: 54:48:e6:5d:1d:0c
- name: yeelight-lightbar
ip: 9
mac: 54:48:e6:23:5e:8e
- name: hue-sync
ip: 10
mac: c4:29:96:03:d1:fe
- name: gree-ac
ip: 13
mac: f4:91:1e:47:e3:bd
- name: livingroom-tv
ip: 15
mac: c0:48:e6:1f:ca:a7
- name: bedroom-tv
ip: 16
mac: d8:a3:5c:7d:50:0a
- name: miibox
ip: 17
mac: 00:e0:4c:68:09:35
- name: nvidia-shield
ip: 18
mac: 00:04:4b:cd:a6:5b
mac2: 00:04:4b:cd:a6:59
- name: nintendo-switch
ip: 19
mac: 64:b5:c6:6f:ff:a8
mac2: 00:0e:c6:c7:55:6f
- name: printer
ip: 20
mac: 38:9d:92:d0:6d:8e
- name: xbox-series-s
ip: 21
mac: a8:8c:3e:b0:aa:7a
- name: oculus-quest-2
ip: 22
mac: b4:17:a8:37:ae:dc
- name: elgato-keylight-mini
ip: 23
mac: 3c:6a:9d:20:42:08
- name: prusa-mini
ip: 24
mac: 10:9c:70:08:ee:e5
- name: presence-sensor
ip: 25
mac: cc:b5:d1:85:4f:4f
- name: prusa-mk39
ip: 26
mac: 10:9c:70:08:ee:e5
- name: twinkly-1
ip: 27
mac: 8c:4b:14:a9:bc:4c
- name: oculus-quest-3
ip: 28
mac: a6:b0:36:17:4f:00
- name: Sonos-LivingRoom
ip: 30
mac: 34:7e:5c:83:6f:c6
- name: Sonos-Bedroom
ip: 31
mac: 78:28:ca:84:d9:10
- name: Sonos-Bathroom
ip: 32
mac: 5c:aa:fd:b9:4b:22
- name: Sonos-Bedroom2
ip: 33
mac: 78:28:ca:85:51:dc
- name: wled-office-monitor
ip: 40
mac: ec:fa:bc:27:e6:4e
- name: wled-lightbar
ip: 41
mac: 5c:cf:7f:23:5e:8e
- name: wled-star
ip: 42
mac: 5c:cf:7f:23:5e:8e
- name: home-assistant
ip: 100
mac: dc:a6:32:f6:63:c1
- name: usb-switch-1
ip: 111
mac: c8:2b:96:64:6a:37
- name: usb-switch-2
ip: 112
mac: c8:2b:96:64:68:a3
- name: usb-switch-3
ip: 113
mac: c8:2b:96:64:67:89
- name: pc-pwr
ip: 114
mac: e8:db:84:49:c1:b6
- name: bt-proxy-1
ip: 115
mac: 24:62:ab:ff:18:a8
- name: bt-proxy-bathroom
ip: 116
mac: e0:5a:1b:d1:5a:74
- name: rack-pwr
ip: 117
mac: 48:55:19:46:18:85
guest:
network: 192.168.70
management:
network: 192.168.1
hosts:
- name: router
ip: 1
- name: switch
ip: 2
- name: switch-desktop
ip: 3
- name: switch-bedroom
ip: 4
- name: switch-rack
ip: 5
- name: access-point
ip: 50
cctv:
network: 192.168.110
hosts:
- name: camera-3dprinter
ip: 11
mac: 34:ce:00:b2:62:3c
- name: camera-kitchen
ip: 12
mac: 78:11:dc:7b:4d:04
- name: camera-hallway
ip: 13
mac: 78:11:DC:7B:4C:87