adapt for custom use

This commit is contained in:
vincent 2021-10-24 20:54:44 +02:00
parent 4d003cee65
commit e6393cd0bd
6 changed files with 31 additions and 68 deletions

View File

@ -1,8 +1,5 @@
---
dependencies:
- role: debops.secret
galaxy_info:
author: 'Maciej Delmanowski'

View File

@ -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

View File

@ -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 %}

2
tests/inventory Normal file
View File

@ -0,0 +1,2 @@
localhost

4
tests/test.yml Normal file
View File

@ -0,0 +1,4 @@
---
- hosts: all
roles:
- ansible-dhcpd

View File

@ -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: