Merge pull request #11 from redrampage/master
Support of multiple MAC addresses for host declaration and a little fix to failover
This commit is contained in:
commit
6c8afc7d5e
@ -242,7 +242,7 @@ dhcpd_subnet_default:
|
|||||||
routers: '{{ ansible_default_ipv4.gateway | default("") }}'
|
routers: '{{ ansible_default_ipv4.gateway | default("") }}'
|
||||||
comment: 'Generated automatically by Ansible'
|
comment: 'Generated automatically by Ansible'
|
||||||
'6':
|
'6':
|
||||||
subnet: '{{ ansible_default_ipv6.address + "/" + ansible_default_ipv6.prefix }}'
|
subnet: '{{ ansible_default_ipv6.address|default("::1") + "/" + ansible_default_ipv6.prefix }}'
|
||||||
comment: 'Generated automatically by Ansible'
|
comment: 'Generated automatically by Ansible'
|
||||||
|
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ dhcpd_failovers: []
|
|||||||
# .. envvar:: dhcpd_probe
|
# .. envvar:: dhcpd_probe
|
||||||
#
|
#
|
||||||
# Enable or disable ``dhcp-probe`` script
|
# Enable or disable ``dhcp-probe`` script
|
||||||
dhcpd_probe: True
|
dhcpd_probe: False
|
||||||
|
|
||||||
|
|
||||||
# .. envvar:: dhcpd_probe_mail_to
|
# .. envvar:: dhcpd_probe_mail_to
|
||||||
|
@ -289,7 +289,8 @@ hosts. Each dict can have following keys:
|
|||||||
Name of the host
|
Name of the host
|
||||||
|
|
||||||
``ethernet``
|
``ethernet``
|
||||||
Ethernet address of this host
|
Ethernet address of this host, if host has multiple aggregated(bonded) links
|
||||||
|
you may specify their ethernet addresses as a list.
|
||||||
|
|
||||||
``address``
|
``address``
|
||||||
IP address of this host
|
IP address of this host
|
||||||
@ -310,6 +311,11 @@ Examples::
|
|||||||
- hostname: 'examplehost'
|
- hostname: 'examplehost'
|
||||||
address: '10.0.10.1'
|
address: '10.0.10.1'
|
||||||
ethernet: '00:00:00:00:00:00'
|
ethernet: '00:00:00:00:00:00'
|
||||||
|
- hostname: 'bondedhost'
|
||||||
|
address: '10.0.10.2'
|
||||||
|
ethernet:
|
||||||
|
- '00:00:00:00:00:01'
|
||||||
|
- '00:00:00:00:00:02'
|
||||||
|
|
||||||
.. _dhcpd_includes:
|
.. _dhcpd_includes:
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% import 'macros.j2' as print with context %}
|
{% import 'macros.j2' as tpl with context %}
|
||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
{% if dhcpd_authoritative is defined and dhcpd_authoritative %}
|
{% if dhcpd_authoritative is defined and dhcpd_authoritative %}
|
||||||
@ -30,22 +30,22 @@ log-facility {{ dhcpd_log_facility }};
|
|||||||
{% include 'ipxe.j2' %}
|
{% include 'ipxe.j2' %}
|
||||||
{% if dhcpd_keys is defined and dhcpd_keys %}
|
{% if dhcpd_keys is defined and dhcpd_keys %}
|
||||||
{% for key in dhcpd_keys %}
|
{% for key in dhcpd_keys %}
|
||||||
{{ print.key(key) }}
|
{{ tpl.print_key(key) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_zones is defined and dhcpd_zones %}
|
{% if dhcpd_zones is defined and dhcpd_zones %}
|
||||||
{% for zone in dhcpd_zones %}
|
{% for zone in dhcpd_zones %}
|
||||||
{{ print.zone(zone) }}
|
{{ tpl.print_zone(zone) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_classes is defined and dhcpd_classes %}
|
{% if dhcpd_classes is defined and dhcpd_classes %}
|
||||||
{% for class in dhcpd_classes %}
|
{% for class in dhcpd_classes %}
|
||||||
{{ print.class(class) }}
|
{{ tpl.print_class(class) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_failovers is defined and dhcpd_failovers %}
|
{% if dhcpd_failovers is defined and dhcpd_failovers %}
|
||||||
{% for failover in dhcpd_failovers %}
|
{% for failover in dhcpd_failovers %}
|
||||||
{{ print.failover(failover) }}
|
{{ tpl.print_failover(failover) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_shared_networks is defined and dhcpd_shared_networks %}
|
{% if dhcpd_shared_networks is defined and dhcpd_shared_networks %}
|
||||||
@ -63,7 +63,7 @@ shared-network "{{ network.name }}" {
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% for subnet in network.subnets %}
|
{% for subnet in network.subnets %}
|
||||||
|
|
||||||
{{ print.subnet(subnet) | indent(8,true) }}
|
{{ tpl.print_subnet(subnet) | indent(8,true) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,16 +72,16 @@ shared-network "{{ network.name }}" {
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_groups is defined and dhcpd_groups %}
|
{% if dhcpd_groups is defined and dhcpd_groups %}
|
||||||
{% for group in dhcpd_groups %}
|
{% for group in dhcpd_groups %}
|
||||||
{{ print.group(group) }}
|
{{ tpl.print_group(group) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_subnets is defined and dhcpd_subnets %}
|
{% if dhcpd_subnets is defined and dhcpd_subnets %}
|
||||||
{% for subnet in dhcpd_subnets %}
|
{% for subnet in dhcpd_subnets %}
|
||||||
{{ print.subnet(subnet) }}
|
{{ tpl.print_subnet(subnet) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_hosts is defined and dhcpd_hosts %}
|
{% if dhcpd_hosts is defined and dhcpd_hosts %}
|
||||||
{{ print.hosts(dhcpd_hosts) }}
|
{{ tpl.print_hosts(dhcpd_hosts) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if dhcpd_includes is defined and dhcpd_includes %}
|
{% if dhcpd_includes is defined and dhcpd_includes %}
|
||||||
{% for include in dhcpd_includes %}
|
{% for include in dhcpd_includes %}
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
# List of macros for ISC DHCP configuration, IPv4
|
# List of macros for ISC DHCP configuration, IPv4
|
||||||
# ===============================================
|
# ===============================================
|
||||||
#
|
#
|
||||||
# ---- Macro: print.class() ----
|
# ---- Macro: print_class() ----
|
||||||
#}
|
#}
|
||||||
{% macro class(class) %}
|
{% set print = self %}
|
||||||
|
{% macro print_class(class) %}
|
||||||
{% if class.comment is defined and class.comment %}
|
{% if class.comment is defined and class.comment %}
|
||||||
# {{ class.comment }}
|
# {{ class.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -32,9 +33,9 @@ subclass "{{ class.class }}" {{ key }};
|
|||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
{#
|
||||||
#
|
#
|
||||||
# ---- Macro: print.group() ----
|
# ---- Macro: print_group() ----
|
||||||
#}
|
#}
|
||||||
{% macro group(group) %}
|
{% macro print_group(group) %}
|
||||||
{% if group.comment is defined and group.comment %}
|
{% if group.comment is defined and group.comment %}
|
||||||
# {{ group.comment }}
|
# {{ group.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -47,24 +48,24 @@ group {
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if group.groups is defined and group.groups %}
|
{% if group.groups is defined and group.groups %}
|
||||||
{% for group in group.groups %}
|
{% for group in group.groups %}
|
||||||
{{ print.group(group) | indent(8, true) }}
|
{{ print_group(group) | indent(8, true) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if group.subnets is defined and group.subnets %}
|
{% if group.subnets is defined and group.subnets %}
|
||||||
{% for subnet in group.subnets %}
|
{% for subnet in group.subnets %}
|
||||||
{{ print.subnet(subnet) | indent(8, true) }}
|
{{ print_subnet(subnet) | indent(8, true) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if group.hosts is defined and group.hosts %}
|
{% if group.hosts is defined and group.hosts %}
|
||||||
{{ print.hosts(group.hosts) | indent(8, true) }}
|
{{ print_hosts(group.hosts) | indent(8, true) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
{#
|
||||||
#
|
#
|
||||||
# ---- Macro: print.subnet() ----
|
# ---- Macro: print_subnet() ----
|
||||||
#}
|
#}
|
||||||
{% macro subnet(subnet) %}
|
{% macro print_subnet(subnet) %}
|
||||||
{% if subnet.comment is defined and subnet.comment %}
|
{% if subnet.comment is defined and subnet.comment %}
|
||||||
# {{ subnet.comment }}
|
# {{ subnet.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -113,15 +114,15 @@ subnet {{ subnet.subnet | ipaddr('cidr') | ipaddr('address') }} netmask 255.255.
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if subnet.hosts is defined and subnet.hosts %}
|
{% if subnet.hosts is defined and subnet.hosts %}
|
||||||
{{ print.hosts(subnet.hosts) | indent(8, true) }}
|
{{ print_hosts(subnet.hosts) | indent(8, true) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
{#
|
||||||
#
|
#
|
||||||
# ---- Macro: print.hosts() ----
|
# ---- Macro: print_hosts() ----
|
||||||
#}
|
#}
|
||||||
{% macro hosts(hosts) %}
|
{% macro print_hosts(hosts) %}
|
||||||
{% if hosts is string %}
|
{% if hosts is string %}
|
||||||
include "{{ hosts }}";
|
include "{{ hosts }}";
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -129,6 +130,23 @@ include "{{ hosts }}";
|
|||||||
{% if host.comment is defined and host.comment %}
|
{% if host.comment is defined and host.comment %}
|
||||||
# {{ host.comment }}
|
# {{ host.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{# Hack to support host with multiple MACs #}
|
||||||
|
{% if host.ethernet is defined and host.ethernet is sequence and not host.ethernet is string %}
|
||||||
|
{% for hwaddr in host.ethernet %}
|
||||||
|
host {{ host.hostname }}-hw{{ loop.index }} {
|
||||||
|
{% if host.options is defined and host.options %}
|
||||||
|
{{ host.options | indent(8,true) }}
|
||||||
|
{% endif %}
|
||||||
|
hardware ethernet {{ hwaddr }};
|
||||||
|
{% if not host.options is defined or (host.options and not 'host-name' in host.options) %}
|
||||||
|
option host-name = {{ host.hostname }};
|
||||||
|
{% endif %}
|
||||||
|
{% if host.address is defined and host.address %}
|
||||||
|
fixed-address {{ host.address }};
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
host {{ host.hostname }} {
|
host {{ host.hostname }} {
|
||||||
{% if host.options is defined and host.options %}
|
{% if host.options is defined and host.options %}
|
||||||
{{ host.options | indent(8,true) }}
|
{{ host.options | indent(8,true) }}
|
||||||
@ -144,19 +162,20 @@ host {{ host.hostname }} {
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
{#
|
||||||
#
|
#
|
||||||
# ---- Macro: print.failover() ----
|
# ---- Macro: print_failover() ----
|
||||||
#}
|
#}
|
||||||
{% macro failover(failover) %}
|
{% macro print_failover(failover) %}
|
||||||
{% if failover.comment is defined and failover.comment %}
|
{% if failover.comment is defined and failover.comment %}
|
||||||
# {{ failover.comment }}
|
# {{ failover.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
failover peer "{{ failover.failover }}" {
|
failover peer "{{ failover.failover }}" {
|
||||||
{% if failover.primary is defined and failover.primary == inventory_hostname %}
|
{% if failover.primary is defined and failover.primary in ansible_all_ipv4_addresses %}
|
||||||
primary;
|
primary;
|
||||||
mclt {{ failover.mclt|default(3600) }};
|
mclt {{ failover.mclt|default(3600) }};
|
||||||
{% if failover.primary_fo_addr is defined and failover.primary_fo_addr %}
|
{% if failover.primary_fo_addr is defined and failover.primary_fo_addr %}
|
||||||
@ -211,9 +230,9 @@ failover peer "{{ failover.failover }}" {
|
|||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
{#
|
||||||
#
|
#
|
||||||
# ---- Macro: print.key() ----
|
# ---- Macro: print_key() ----
|
||||||
#}
|
#}
|
||||||
{% macro key(key) %}
|
{% macro print_key(key) %}
|
||||||
{% if key.comment is defined and key.comment %}
|
{% if key.comment is defined and key.comment %}
|
||||||
# {{ key.comment }}
|
# {{ key.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -224,9 +243,9 @@ key {{ key.key }} {
|
|||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
{#
|
{#
|
||||||
#
|
#
|
||||||
# ---- Macro: print.zone() ----
|
# ---- Macro: print_zone() ----
|
||||||
#}
|
#}
|
||||||
{% macro zone(zone) %}
|
{% macro print_zone(zone) %}
|
||||||
{% if zone.comment is defined and zone.comment %}
|
{% if zone.comment is defined and zone.comment %}
|
||||||
# {{ zone.comment }}
|
# {{ zone.comment }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user