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: galaxy_info:
author: 'Maciej Delmanowski' author: 'Maciej Delmanowski'

View File

@ -1,5 +1,4 @@
--- ---
- include: dist_vars.yml - include: dist_vars.yml
- include: install.yml - include: install.yml
@ -17,25 +16,25 @@
- name: Configure DHCP server - name: Configure DHCP server
template: template:
src: '{{ item }}.j2' src: "etc/dhcp/dhcpd.conf.j2"
dest: '/{{ item }}' dest: "/{{ item }}"
owner: 'root' owner: "root"
group: 'root' group: "root"
mode: '0644' mode: "0644"
with_items: "{{ dhcpd_templates }}" with_items: "{{ dhcpd_templates }}"
notify: [ 'Restart dhcp server' ] notify: ["Restart dhcp server"]
register: dhcpd_register_config register: dhcpd_register_config
when: dhcpd_mode == 'server' when: dhcpd_mode == 'server'
- name: Make sure that included files exist - name: Make sure that included files exist
file: file:
path: '{{ item }}' path: "{{ item }}"
state: 'touch' state: "touch"
owner: 'root' owner: "root"
group: 'root' group: "root"
mode: '0644' mode: "0644"
with_items: '{{ dhcpd_includes }}' with_items: "{{ dhcpd_includes }}"
notify: [ 'Restart dhcp server' ] notify: ["Restart dhcp server"]
when: ((item is defined and item) and dhcpd_mode == 'server' and 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))

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: dhcpd_base_packages_map:
'server': "server":
- 'dhcp' - "dhcp"
'relay': "relay":
- 'dhcp' - "dhcp"
'probe': [] "probe": []
dhcpd_services: dhcpd_services:
'server': "server":
- 'dhcpd4' - "dhcpd4"
- 'dhcpd6' "relay":
'relay': - "dhcpd4"
- 'dhcpd4' "probe": []
- 'dhcpd6'
'probe': []
dhcpd_templates: dhcpd_templates:
- 'etc/dhcp/dhcpd.conf' - "etc/dhcpd.conf"
# vim: set ts=2 sw=2: # vim: set ts=2 sw=2: