From 79497476c28af85b51d75d7ba7120b77496f45d0 Mon Sep 17 00:00:00 2001 From: pgrondek Date: Tue, 23 Feb 2021 19:37:52 +0100 Subject: [PATCH] Update network --- inventory/hosts.yml | 94 +++++++++++++++++-- roles/network/tasks/dns-file.yml | 9 ++ roles/network/templates/etc/bind/db.lan.j2 | 2 +- .../network/templates/etc/bind/db.reverse.j2 | 15 +++ roles/network/vars/main.yml | 28 ++++-- 5 files changed, 128 insertions(+), 20 deletions(-) create mode 100644 roles/network/templates/etc/bind/db.reverse.j2 diff --git a/inventory/hosts.yml b/inventory/hosts.yml index 4e0a039..4d01320 100644 --- a/inventory/hosts.yml +++ b/inventory/hosts.yml @@ -1,17 +1,93 @@ --- all: hosts: - prusa.lan: - iron-man.lan: - router.lan: + router: + ansible_host: 192.168.50.2 + vars: + ip: 2 + mac: 2c:b0:5d:4a:72:62 + bender: + ansible_host: 192.168.50.3 + vars: + ip: 3 + mac: e0:3f:49:6f:03:c2 + + home-assistant: + ansible_host: 192.168.50.5 + vars: + ip: 5 + mac: dc:a6:32:8b:7b:ab + mac2: 6a:1b:c8:63:58:7a + prusa: + ansible_host: 192.168.50.6 + vars: + ip: 6 + mac: b8:27:eb:96:f3:3f + mac2: b8:27:eb:c3:a6:6a +# rpi3-02: + iron-man: + ansible_host: 192.168.50.7 + vars: + ip: 7 + mac: b8:27:eb:19:f8:0d + rpi3a: + ansible_host: 192.168.50.8 + vars: + ip: 8 + mac: b8:27:eb:ff:2a:86 + kvm-bender: + ansible_host: 192.168.50.11 + vars: + ip: 11 + mac: dc:a6:32:f6:63:c1 + android-sgs9: + vars: + ip: 41 + mac: 24:18:1d:bc:fe:4f + ipad: + vars: + ip: 42 + mac: b8:63:4d:b6:4c:bc + node-01.lan: + ansible_host: 192.168.50.101 + vars: + ip: 101 + mac: dc:a6:32:03:6d:fa + node-02.lan: + ansible_host: 192.168.50.102 + vars: + ip: 102 + mac: dc:a6:32:3c:0f:ff + node-03.lan: + ansible_host: 192.168.50.103 + vars: + ip: 103 + mac: dc:a6:32:3c:1a:ec + node-x86.lan: + ansible_host: 192.168.50.186 + vars: + ip: 186 children: - docker_cluster: + raspberry: hosts: node-01.lan: - ansible_host: 192.168.50.101 node-02.lan: - ansible_host: 192.168.50.102 node-03.lan: - ansible_host: 192.168.50.103 - node-x86.lan: - ansible_host: 192.168.50.186 + lan: + hosts: + router: + bender: + home-assistant: + rpi3-01: +# rpi3-02: + iron-man: + prusa: + + + children: + docker_cluster: + hosts: + node-01.lan: + node-02.lan: + node-03.lan: + node-x86.lan: \ No newline at end of file diff --git a/roles/network/tasks/dns-file.yml b/roles/network/tasks/dns-file.yml index 10069dc..ae46507 100644 --- a/roles/network/tasks/dns-file.yml +++ b/roles/network/tasks/dns-file.yml @@ -12,3 +12,12 @@ vars: network: "{{ lan }}" serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02" + +- name: Create db.lan +# become: yes + template: + src: etc/bind/db.reverse.j2 + dest: build/dns/db.{{ lan.network_reverse }} + vars: + network: "{{ lan }}" + serial: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}02" diff --git a/roles/network/templates/etc/bind/db.lan.j2 b/roles/network/templates/etc/bind/db.lan.j2 index 46ecb2c..76a3f40 100644 --- a/roles/network/templates/etc/bind/db.lan.j2 +++ b/roles/network/templates/etc/bind/db.lan.j2 @@ -8,7 +8,7 @@ $ORIGIN {{ network.network_name }}. 86400; ) -@ IN NS dns.lan. +@ IN NS dns.{{ network.network_name }}. DNS IN A {{ network.network_prefix }}.100 diff --git a/roles/network/templates/etc/bind/db.reverse.j2 b/roles/network/templates/etc/bind/db.reverse.j2 new file mode 100644 index 0000000..991aca5 --- /dev/null +++ b/roles/network/templates/etc/bind/db.reverse.j2 @@ -0,0 +1,15 @@ +$TTL 86400 +$ORIGIN {{ network.network_name }}. +@ IN SOA {{ network.network_name }}. dns.{{ network.network_name }}. ( + {{ serial }}; + 604800; + 86400; + 2419200; + 86400; +) + +{{ network.network_reverse }} IN A dns.{{ network.network_name }} + +{% for host in network.hosts %} +{{ host.ip }} IN PTR {{ host.name }} +{% endfor %} \ No newline at end of file diff --git a/roles/network/vars/main.yml b/roles/network/vars/main.yml index 0cbdbb5..0b427a3 100644 --- a/roles/network/vars/main.yml +++ b/roles/network/vars/main.yml @@ -1,6 +1,7 @@ --- lan: network_prefix: 192.168.50 + network_reverse: 50.168.192 network_name: lan address: 192.168.50.0 mask: 255.255.255.0 @@ -15,29 +16,36 @@ lan: - name: bender ip: 3 mac: e0:3f:49:6f:03:c2 - - name: prusa-new - ip: 4 - mac: b8:27:eb:96:f3:3f - mac2: b8:27:eb:c3:a6:6a - name: home-assistant ip: 5 mac: dc:a6:32:8b:7b:ab mac2: 6a:1b:c8:63:58:7a + - name: prusa + ip: 6 + mac: b8:27:eb:96:f3:3f + mac2: b8:27:eb:c3:a6:6a +# - name: rpi3 - name: iron-man ip: 7 mac: dc:a6:32:03:6d:fa - - name: prusa + - name: rpi3a ip: 8 mac: b8:27:eb:ff:2a:86 - - name: farnsworth + - name: kvm-bender + ip: 11 + mac: dc:a6:32:f6:63:c1 + - name: hulk ip: 21 + mac: 24:4b:fe:05:e2:8b + - name: farnsworth + ip: 22 mac: e0:3f:49:83:e8:dd - - name: ipad - ip: 46 - mac: b8:63:4d:b6:4c:bc - name: android-sgs9 - ip: 47 + ip: 41 mac: 24:18:1d:bc:fe:4f + - name: ipad + ip: 42 + mac: b8:63:4d:b6:4c:bc - name: node-01 ip: 101 mac: dc:a6:32:03:6d:fa