Add more options in dhcpd.conf (#16)
* Add more global options in dhcpd.conf * Add failover peer block in dhcpd.conf * Add more options in the subnet block * Add a few example pillar data based on the previous additions * add double quotes for each single entry in option domain-search
This commit is contained in:
Родитель
29c74bcfe8
Коммит
25aafbd54f
|
@ -32,6 +32,18 @@ default-lease-time {{ salt['pillar.get']('dhcpd:default_lease_time') }};
|
|||
{% if salt['pillar.get']('dhcpd:max_lease_time', False) -%}
|
||||
max-lease-time {{ salt['pillar.get']('dhcpd:max_lease_time') }};
|
||||
{% endif -%}
|
||||
{% if salt['pillar.get']('dhcpd:one_lease_per_client', False) -%}
|
||||
one-lease-per-client {{ salt['pillar.get']('dhcpd:one_lease_per_client') }};
|
||||
{% endif -%}
|
||||
{% if salt['pillar.get']('dhcpd:get_lease_hostnames', False) -%}
|
||||
get-lease-hostnames {{ salt['pillar.get']('dhcpd:get_lease_hostnames') }};
|
||||
{% endif -%}
|
||||
{% if salt['pillar.get']('dhcpd:server_identifier') -%}
|
||||
server-identifier {{ salt['pillar.get']('dhcpd:server_identifier') }};
|
||||
{% endif -%}
|
||||
{% if salt['pillar.get']('dhcpd:server_name') -%}
|
||||
server-name {{ dquote }}{{ salt['pillar.get']('dhcpd:server_name') }}{{ dquote }};
|
||||
{% endif -%}
|
||||
{%- if salt['pillar.get']('dhcpd:allow', False) %}
|
||||
allow {{ salt['pillar.get']('dhcpd:allow') }};
|
||||
{%- elif salt['pillar.get']('dhcpd:deny', False) %}
|
||||
|
@ -70,6 +82,62 @@ option {{ option|replace('_', '-') }} {{ quote }}{{ salt['pillar.get']('dhcpd:'
|
|||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{%- for failover_peer, config in salt['pillar.get']('dhcpd:failover_peers', {}).items() %}
|
||||
{%- if config.has_key('comment') %}
|
||||
{%- for line in config.comment.splitlines() %}
|
||||
# {{ line }}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
failover peer "{{ failover_peer }}" {
|
||||
{%- if config.has_key('primary') %}
|
||||
primary;
|
||||
{%- elif config.has_key('secondary') %}
|
||||
secondary;
|
||||
{%- endif %}
|
||||
{%- if config.has_key('address') %}
|
||||
address {{ config.address }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('port') %}
|
||||
port {{ config.port }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('peer_address') %}
|
||||
peer address {{ config.peer_address }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('peer_port') %}
|
||||
peer port {{ config.port }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('max_response_delay') %}
|
||||
max-response-delay {{ config.max_response_delay }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('max_unacked_updates') %}
|
||||
max-unacked-updates {{ config.max_unacked_updates }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('mclt') %}
|
||||
mclt {{ config.mclt }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('split') %}
|
||||
split {{ config.split }};
|
||||
{%- elif config.has_key('hba') %}
|
||||
hba {{ config.hba }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('load_balance_max_seconds') %}
|
||||
load balance max seconds {{ config.load_balance_max_seconds }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('max_lease_misbalance') %}
|
||||
max-lease-misbalance {{ config.max_lease_misbalance }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('max_lease_ownership') %}
|
||||
max-lease-ownership {{ config.max_lease_ownership }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('min_balance') %}
|
||||
min-balance {{ config.min_balance }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('max-balance') %}
|
||||
max-balance {{ config.max_balance }};
|
||||
{%- endif %}
|
||||
}
|
||||
{%- endfor %}
|
||||
|
||||
{%- set intendation='' %}
|
||||
{%- for subnet, config in salt['pillar.get']('dhcpd:subnets', {}).items() %}
|
||||
{%- include 'dhcpd/files/subnet.jinja' with context %}
|
||||
|
|
|
@ -31,15 +31,36 @@
|
|||
{%- if config.has_key('ntp_servers') %}
|
||||
{{ intendation }} option ntp-servers {{ config['ntp_servers']|join(',') }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('lpr_servers') %}
|
||||
{{ intendation }} option lpr-servers {{ config['lpr_servers']|join(',') }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('irc_server') %}
|
||||
{{ intendation }} option irc-server {{ config['irc_server']|join(',') }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('tftp_server_name') %}
|
||||
{{ intendation }} option tftp-server-name "{{ config['tftp_server_name'] }}";
|
||||
{%- endif %}
|
||||
{%- if config.has_key('smtp_server') %}
|
||||
{{ intendation }} option smtp-server {{ config['smtp_server'] }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('domain_name') %}
|
||||
{{ intendation }} option domain-name "{{ config['domain_name'] }}";
|
||||
{%- endif %}
|
||||
{%- if config.has_key('domain_search') %}
|
||||
{{ intendation }} option domain-search "{{ config['domain_search']|join('","') }}";
|
||||
{%- endif %}
|
||||
{%- if config.has_key('filename') %}
|
||||
{{ intendation }} filename "{{ config['filename'] }}";
|
||||
{%- endif %}
|
||||
{%- if config.has_key('next_server') %}
|
||||
{{ intendation }} next-server {{ config['next_server'] }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('default_lease_time') %}
|
||||
{{ intendation }} default-lease-time {{ config['default_lease_time'] }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('max_lease_time') %}
|
||||
{{ intendation }} max-lease-time {{ config['max_lease_time'] }};
|
||||
{%- endif %}
|
||||
{%- if config.has_key('routers') and config.routers is string %}
|
||||
{{ intendation }} option routers {{ config.routers }};
|
||||
{%- elif config.has_key('routers') and config.routers is sequence %}
|
||||
|
@ -54,4 +75,14 @@
|
|||
{{ intendation }} option {{ option|replace('_', '-') }} {{ quote }}{{ config.get(option) }}{{ quote }};
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- for pool in salt['pillar.get']('dhcpd:subnets:{0}:pools'.format(subnet), []) %}
|
||||
{{ intendation }} pool {
|
||||
{%- if pool.has_key('failover_peer') %}
|
||||
{{ intendation }} failover peer "{{ pool['failover_peer'] }}";
|
||||
{%- endif %}
|
||||
{%- if pool.has_key('range') %}
|
||||
{{ intendation }} range {{ pool.range[0] }} {{ pool.range[1] }};
|
||||
{%- endif %}
|
||||
{{ intendation }} }
|
||||
{%- endfor %}
|
||||
{{ intendation }}}
|
||||
|
|
|
@ -6,12 +6,24 @@ dhcpd:
|
|||
default_lease_time: 600
|
||||
max_lease_time: 7200
|
||||
log_facility: local7
|
||||
failover_peers:
|
||||
dhcp-failover:
|
||||
primary: true
|
||||
address: 10.152.187.5
|
||||
port: 647
|
||||
peer_address: 10.152.187.6
|
||||
peer_port: 647
|
||||
subnets:
|
||||
10.152.187.0:
|
||||
comment: |
|
||||
No service will be given on this subnet, but declaring it helps the
|
||||
DHCP server to understand the network topology.
|
||||
netmask: 255.255.255.0
|
||||
pools:
|
||||
- failover_peer: dhcp-failover
|
||||
range:
|
||||
- 10.152.187.1
|
||||
- 10.152.187.254
|
||||
|
||||
10.254.239.0:
|
||||
comment: This is a very basic subnet declaration.
|
||||
|
|
Загрузка…
Ссылка в новой задаче