From e6393cd0bd26d72def04025ff7f20a5147d13299 Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 24 Oct 2021 20:54:44 +0200 Subject: [PATCH] adapt for custom use --- meta/main.yml | 3 -- tasks/main.yml | 29 ++++++++++---------- templates/etc/default/isc-dhcp-server.j2 | 35 ------------------------ tests/inventory | 2 ++ tests/test.yml | 4 +++ vars/Archlinux.yml | 26 ++++++++---------- 6 files changed, 31 insertions(+), 68 deletions(-) delete mode 100644 templates/etc/default/isc-dhcp-server.j2 create mode 100644 tests/inventory create mode 100644 tests/test.yml diff --git a/meta/main.yml b/meta/main.yml index 645627c..b1d0ece 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,8 +1,5 @@ --- -dependencies: - - - role: debops.secret galaxy_info: author: 'Maciej Delmanowski' diff --git a/tasks/main.yml b/tasks/main.yml index 2a62b13..d29ecff 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,4 @@ --- - - include: dist_vars.yml - include: install.yml @@ -17,27 +16,27 @@ - name: Configure DHCP server template: - src: '{{ item }}.j2' - dest: '/{{ item }}' - owner: 'root' - group: 'root' - mode: '0644' + src: "etc/dhcp/dhcpd.conf.j2" + dest: "/{{ item }}" + owner: "root" + group: "root" + mode: "0644" with_items: "{{ dhcpd_templates }}" - notify: [ 'Restart dhcp server' ] + notify: ["Restart dhcp server"] register: dhcpd_register_config when: dhcpd_mode == 'server' - name: Make sure that included files exist file: - path: '{{ item }}' - state: 'touch' - owner: 'root' - group: 'root' - mode: '0644' - with_items: '{{ dhcpd_includes }}' - notify: [ 'Restart dhcp server' ] + path: "{{ item }}" + state: "touch" + owner: "root" + group: "root" + mode: "0644" + with_items: "{{ dhcpd_includes }}" + notify: ["Restart dhcp server"] when: ((item is defined and item) and dhcpd_mode == 'server' and - (dhcpd_register_config is defined and dhcpd_register_config.changed)) + (dhcpd_register_config is defined and dhcpd_register_config.changed)) - name: Make sure that IPv6 lease file exists command: touch /var/lib/dhcp/dhcpd6.leases creates=/var/lib/dhcp/dhcpd6.leases diff --git a/templates/etc/default/isc-dhcp-server.j2 b/templates/etc/default/isc-dhcp-server.j2 deleted file mode 100644 index 69347d7..0000000 --- a/templates/etc/default/isc-dhcp-server.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# This file is managed by Ansible, all changes will be lost - -# Defaults for isc-dhcp-server initscript -# sourced by /etc/init.d/isc-dhcp-server -# installed at /etc/default/isc-dhcp-server by the maintainer scripts - -# -# This is a POSIX shell fragment -# - -# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf). -#DHCPD_CONF=/etc/dhcp/dhcpd.conf - -# Path to dhcpd's PID file (default: /var/run/dhcpd.pid). -#DHCPD_PID=/var/run/dhcpd.pid - -# Additional options to start dhcpd with. -# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead -OPTIONS="{{ dhcpd_server_options }}" - -# On what interfaces should the DHCP server (dhcpd) serve DHCP requests? -# Separate multiple interfaces with spaces, e.g. "eth0 eth1". -{% if dhcpd_interfaces is defined and dhcpd_interfaces %} -INTERFACES="{{ dhcpd_interfaces | join(' ') }}" -{% else %} -{% set dhcpd_tpl_interfaces = [] %} -{% for interface in ansible_interfaces %} -{% if interface != 'lo' and ((hostvars[inventory_hostname]['ansible_'+interface].ipv4 is defined and hostvars[inventory_hostname]['ansible_'+interface].ipv4) or (hostvars[inventory_hostname]['ansible_'+interface].ipv6 is defined and hostvars[inventory_hostname]['ansible_'+interface].ipv6)) %} -{% if dhcpd_tpl_interfaces.append(interface) %}{% endif %} -{% endif %} -{% endfor %} -INTERFACES="{{ dhcpd_tpl_interfaces | join(' ') }}" -{% endif %} - - diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..b57d04f --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: all + roles: + - ansible-dhcpd diff --git a/vars/Archlinux.yml b/vars/Archlinux.yml index e460024..f2d3ef1 100644 --- a/vars/Archlinux.yml +++ b/vars/Archlinux.yml @@ -1,22 +1,18 @@ --- - dhcpd_base_packages_map: - 'server': - - 'dhcp' - 'relay': - - 'dhcp' - 'probe': [] + "server": + - "dhcp" + "relay": + - "dhcp" + "probe": [] dhcpd_services: - 'server': - - 'dhcpd4' - - 'dhcpd6' - 'relay': - - 'dhcpd4' - - 'dhcpd6' - 'probe': [] + "server": + - "dhcpd4" + "relay": + - "dhcpd4" + "probe": [] dhcpd_templates: - - 'etc/dhcp/dhcpd.conf' - + - "etc/dhcpd.conf" # vim: set ts=2 sw=2: