From 838efc0554cf789499ca53e098226a5a21413101 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Thu, 2 Sep 2021 19:11:19 +0000 Subject: [PATCH] Add dhcp server to print servers --- group_vars/print.yml | 2 ++ playbooks/print.yml | 9 ++++-- roles/dhcpd/templates/dhcpd.conf.print.j2 | 38 +++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 roles/dhcpd/templates/dhcpd.conf.print.j2 diff --git a/group_vars/print.yml b/group_vars/print.yml index 5142664..7029178 100644 --- a/group_vars/print.yml +++ b/group_vars/print.yml @@ -7,6 +7,8 @@ network_vip_interfaces: pass: "{{ vip24_pass }}" priority: "{{ vip24_priority }}" +dhcpd_template: dhcpd.conf.print.j2 + firewall_in: - {proto: tcp, port: 22, from: [172.20.20.0/22]} - {proto: tcp, port: 53, from: [172.20.24.0/24]} diff --git a/playbooks/print.yml b/playbooks/print.yml index 0e0159f..b897670 100644 --- a/playbooks/print.yml +++ b/playbooks/print.yml @@ -15,6 +15,12 @@ - mkhomedir tasks: + - name: run handlers to get interfaces configured + meta: flush_handlers + + - import_role: + name: dhcpd + - name: copy dns zone files copy: dest: "/var/lib/unbound/{{ item }}" @@ -30,9 +36,6 @@ - import_role: name: unbound - - name: run handlers to get nsswitch configured - meta: flush_handlers - - import_role: name: cups-server - import_role: diff --git a/roles/dhcpd/templates/dhcpd.conf.print.j2 b/roles/dhcpd/templates/dhcpd.conf.print.j2 new file mode 100644 index 0000000..ca0ab35 --- /dev/null +++ b/roles/dhcpd/templates/dhcpd.conf.print.j2 @@ -0,0 +1,38 @@ + +authorative; +ddns-update-style none; + +# logging +on commit { + log(info, + concat("Client ", + binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)), + " requests ", + binary-to-ascii(16, 8, ":", option dhcp-parameter-request-list), + " - ", + pick-first-value(option vendor-class-identifier, "no vendor-id"), + " - ", + pick-first-value(option user-class, "no user-class")) + ); +} + +shared-network PRINTNET { + + subnet 172.20.24.0 netmask 255.255.255.0 { + default-lease-time 86400; + max-lease-time 604800; + option subnet-mask 255.255.255.0; + option broadcast-address 172.20.24.255; + + option domain-name "print.foo.sh"; + option domain-name-servers 172.20.24.1, 172.20.24.2, 172.20.24.3; + use-host-decl-names on; + } + + host hp1.print.foo.sh { + option host-name "hp1.print.foo.sh"; + hardware ethernet 00:15:99:22:79:46; + fixed-address 172.20.24.101; + } + +}