WIP3
This commit is contained in:
13
roles/sage905.dhcp/.gitignore
vendored
Normal file
13
roles/sage905.dhcp/.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# .gitignore
|
||||
|
||||
# Hidden Vagrant-directory
|
||||
.vagrant
|
||||
|
||||
# Backup files (e.g. Vim, Gedit, etc.)
|
||||
*~
|
||||
|
||||
# Vagrant base boxes (you never know when someone puts one in the repository)
|
||||
*.box
|
||||
|
||||
# Ignore test code (it's a separate branch worktree)
|
||||
*tests/
|
||||
21
roles/sage905.dhcp/.yamllint
Normal file
21
roles/sage905.dhcp/.yamllint
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
# Based on ansible-lint config
|
||||
extends: default
|
||||
|
||||
rules:
|
||||
braces: {max-spaces-inside: 1, level: error}
|
||||
brackets: {max-spaces-inside: 1, level: error}
|
||||
colons: {max-spaces-after: -1, level: error}
|
||||
commas: {max-spaces-after: -1, level: error}
|
||||
comments: disable
|
||||
comments-indentation: disable
|
||||
document-start: disable
|
||||
empty-lines: {max: 3, level: error}
|
||||
hyphens: {level: error}
|
||||
indentation: disable
|
||||
key-duplicates: enable
|
||||
line-length: disable
|
||||
new-line-at-end-of-file: disable
|
||||
new-lines: {type: unix}
|
||||
trailing-spaces: disable
|
||||
truthy: disable
|
||||
233
roles/sage905.dhcp/README.md
Normal file
233
roles/sage905.dhcp/README.md
Normal file
@@ -0,0 +1,233 @@
|
||||
# Ansible role `dhcp`
|
||||
|
||||
Ansible role for setting up ISC DHCPD. The responsibilities of this role are to install packages and manage the configuration ([dhcpd.conf(5)](http://linux.die.net/man/5/dhcpd.conf)). Managing the firewall configuration is NOT a concern of this role. You can do this in your local playbook, or use another role (e.g. [bertvv.rh-base](https://galaxy.ansible.com/bertvv/rh-base).
|
||||
|
||||
Refer to the [change log](CHANGELOG.md) for notable changes in each release.
|
||||
|
||||
Do you use/like this role? Please consider giving it a star. If you [rate this role](https://galaxy.ansible.com/bertvv/dhcp) on Ansible Galaxy and find it lacking in some respect, please consider opening an Issue with actionable feedback or a PR so we can improve it. Thank you!
|
||||
|
||||
## Requirements
|
||||
|
||||
No specific requirements
|
||||
|
||||
## Role Variables
|
||||
|
||||
This role is able to set global options, and to specify subnet declarations.
|
||||
|
||||
See the [test playbook](https://github.com/bertvv/ansible-role-dhcp/blob/vagrant-tests/test.yml) for a working example of a DHCP server in a test environment based on Vagrant and VirtualBox. This section is a reference of all supported options.
|
||||
|
||||
### Global options
|
||||
|
||||
The following variables, when set, will be added to the global section of the DHCP configuration file. If there is no default value specified, the corresponding setting will be left out of `dhcpd.conf(5)`.
|
||||
|
||||
See the [dhcp-options(5)](http://linux.die.net/man/5/dhcp-options) man page for more information about these options.
|
||||
|
||||
| Variable | Comments |
|
||||
| :--- | :--- |
|
||||
| `dhcp_global_authoritative` | Global authoritative statement (`authoritative`, `not authoritative`) |
|
||||
| `dhcp_global_booting` | Global booting (`allow`, `deny`, `ignore`) |
|
||||
| `dhcp_global_bootp` | Global bootp (`allow`, `deny`, `ignore`) |
|
||||
| `dhcp_global_broadcast_address` | Global broadcast address |
|
||||
| `dhcp_global_classes` | Class definitions with a match statement(1) |
|
||||
| `dhcp_global_default_lease_time` | Default lease time in seconds |
|
||||
| `dhcp_global_domain_name_servers` | A list of IP addresses of DNS servers(2) |
|
||||
| `dhcp_global_domain_name` | The domain name the client should use when resolving host names |
|
||||
| `dhcp_global_domain_search` | A list of domain names to be used by the client to locate non-FQDNs(1) |
|
||||
| `dhcp_global_failover` | Failover peer settings (3) |
|
||||
| `dhcp_global_failover_peer` | Name for the failover peer (e.g. `foo`) |
|
||||
| `dhcp_global_filename` | Filename to request for boot |
|
||||
| `dhcp_global_includes_missing` | Boolean. Continue if `includes` file(s) missing from role's files/ |
|
||||
| `dhcp_global_includes` | List of config files to be included (from `dhcp_config_dir`) |
|
||||
| `dhcp_global_log_facility` | Global log facility (e.g. `daemon`, `syslog`, `user`, ...) |
|
||||
| `dhcp_global_max_lease_time` | Maximum lease time in seconds |
|
||||
| `dhcp_global_next_server` | IP for PXEboot server |
|
||||
| `dhcp_global_ntp_servers` | List of IP addresses of NTP servers |
|
||||
| `dhcp_global_omapi_port` | OMAPI port |
|
||||
| `dhcp_global_omapi_secret` | OMAPI secret |
|
||||
| `dhcp_global_other_options` | Array of arbitrary additional global options |
|
||||
| `dhcp_global_routers` | IP address of the router |
|
||||
| `dhcp_global_server_name` | Server name sent to the client |
|
||||
| `dhcp_global_server_state` | Service state (started, stopped) |
|
||||
| `dhcp_global_subnet_mask` | Global subnet mask |
|
||||
|
||||
**Remarks**
|
||||
|
||||
(1) This role supports the definition of classes with a match statement, e.g.:
|
||||
|
||||
```Yaml
|
||||
# Class for VirtualBox VMs
|
||||
dhcp_global_classes:
|
||||
- name: vbox
|
||||
match: 'match if binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "8:0:27"'
|
||||
```
|
||||
|
||||
Class names can be used in the definition of address pools (see below).
|
||||
|
||||
(2) The role variable `dhcp_global_domain_name_servers` may be written either as a list (when you have more than one item), or as a string (when you have only one). The following snippet shows an example of both:
|
||||
|
||||
```Yaml
|
||||
# A single DNS server
|
||||
dhcp_global_domain_name_servers: 8.8.8.8
|
||||
|
||||
# A list of DNS servers
|
||||
dhcp_global_domain_name_servers:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
```
|
||||
|
||||
(3) This role also supports the definition of a failover peer, e.g.:
|
||||
|
||||
```Yaml
|
||||
# Failover peer definition
|
||||
dhcp_global_failover_peer: failover-group
|
||||
dhcp_global_failover:
|
||||
role: primary # | secondary
|
||||
address: 192.168.222.2
|
||||
port: 647
|
||||
peer_address: 192.168.222.3
|
||||
peer_port: 647
|
||||
max_response_delay: 15
|
||||
max_unacked_updates: 10
|
||||
load_balance_max_seconds: 5
|
||||
split: 255
|
||||
mclt: 3600
|
||||
```
|
||||
|
||||
The variable `dhcp_global_failover_peer` contains a name for the configured peer, to be used on a per pool basis. The failover declaration options are specified with the variable `dhcp_global_failover`, a dictionary that may contain the following options:
|
||||
|
||||
| Option | Required | Comment |
|
||||
| :--- | :---: | :-- |
|
||||
| `address` | no | This server's IP address |
|
||||
| `hba` | no | colon-separated-hex-list |
|
||||
| `load_balance_max_seconds` | no | Cutoff after which load balance is disabled (3 to 5 recommended) |
|
||||
| `max-balance` | no | Failover pool balance statement |
|
||||
| `max-lease-misbalance` | no | Failover pool balance statement |
|
||||
| `max-lease-ownership` | no | Failover pool balance statement |
|
||||
| `max_response_delay` | no | Maximum seconds without contact before engaging failover |
|
||||
| `max_unacked_updates` | no | Maximum BNDUPD it can send before receiving a BNDACK (10 recommended) |
|
||||
| `mclt` | no | Maximum Client Lead Time |
|
||||
| `min-balance` | no | Failover pool balance statement |
|
||||
| `peer_address` | no | Failover peer's IP addres |
|
||||
| `peer_port` | no | This server's port (generally 519/520 or 647/847) |
|
||||
| `port` | no | This server's port (generally 519/520 or 647/847) |
|
||||
| `role` | no | primary, secondary |
|
||||
| `split` | no | Load balance split (0-255) |
|
||||
|
||||
The failover peer directive has to be in the definition of address pools (see below).
|
||||
|
||||
### Subnet declarations
|
||||
|
||||
The role variable `dhcp_subnets` contains a list of dicts, specifying the subnet declarations to be added to the DHCP configuration file. Every subnet declaration should have an `ip` and `netmask`, other options are not mandatory. We start this section with an example, a complete overview of supported options follows.
|
||||
|
||||
```Yaml
|
||||
dhcp_subnets:
|
||||
- ip: 192.168.222.0
|
||||
netmask: 255.255.255.128
|
||||
domain_name_servers:
|
||||
- 10.0.2.3
|
||||
- 10.0.2.4
|
||||
range_begin: 192.168.222.50
|
||||
range_end: 192.168.222.127
|
||||
- ip: 192.168.222.128
|
||||
default_lease_time: 3600
|
||||
max_lease_time: 7200
|
||||
netmask: 255.255.255.128
|
||||
domain_name_servers: 10.0.2.3
|
||||
routers: 192.168.222.129
|
||||
```
|
||||
|
||||
An alphabetical list of supported options in a subnet declaration:
|
||||
|
||||
| Option | Required | Comment |
|
||||
| :--- | :---: | :-- |
|
||||
| `booting` | no | allow,deny,ignore |
|
||||
| `bootp` | no | allow,deny,ignore |
|
||||
| `default_lease_time` | no | Default lease time for this subnet (in seconds) |
|
||||
| `domain_name_servers` | no | List of domain name servers for this subnet(1) |
|
||||
| `domain_search` | no | List of domain names for resolution of non-FQDNs(1) |
|
||||
| `filename` | no | filename to retrieve from boot server |
|
||||
| `hosts` | no | List of fixed IP address hosts for each subnet, similar to dhcp_hosts |
|
||||
| `ip` | yes | **Required.** IP address of the subnet |
|
||||
| `max_lease_time` | no | Maximum lease time for this subnet (in seconds) |
|
||||
| `netmask` | yes | **Required.** Network mask of the subnet (in dotted decimal notation) |
|
||||
| `next_server` | no | IP address of the boot server |
|
||||
| `range_begin` | no | Lowest address in the range of dynamic IP addresses to be assigned |
|
||||
| `range_end` | no | Highest address in the range of dynamic IP addresses to be assigned |
|
||||
| `ranges` | no | If multiple ranges are needed, they can be specified as a list (2) |
|
||||
| `routers` | no | IP address of the gateway for this subnet |
|
||||
| `server_name` | no | Server name sent to the client |
|
||||
| `subnet_mask` | no | Overrides the `netmask` of the subnet declaration |
|
||||
|
||||
You can specify address pools within a subnet by setting the `pools` options. This allows you to specify a pool of addresses that will be treated differently than another pool of addresses, even on the same network segment or subnet. It is a list of dicts with the following keys, all of which are optional:
|
||||
|
||||
| Option | Comment |
|
||||
| :--- | :--- |
|
||||
| `allow` | Specifies which hosts are allowed in this pool(1) |
|
||||
| `default_lease_time` | The default lease time for this pool |
|
||||
| `deny` | Specifies which hosts are not allowed in this pool |
|
||||
| `domain_name_servers` | The domain name servers to be used for this pool(1) |
|
||||
| `max_lease_time` | The maximum lease time for this pool |
|
||||
| `min_lease_time` | The minimum lease time for this pool |
|
||||
| `range_begin` | The lowest address in this pool |
|
||||
| `range_end` | The highest address in this pool |
|
||||
|
||||
(1) For the `allow` and `deny` fields, the options are enumerated in [dhcpd.conf(5)](http://linux.die.net/man/5/dhcpd.conf), but include:
|
||||
|
||||
- `booting`
|
||||
- `bootp`
|
||||
- `client-updates`
|
||||
- `known-clients`
|
||||
- `members of "CLASS"`
|
||||
- `unknown-clients`
|
||||
|
||||
(2) For multiple subnet ranges, they can be specified, thus:
|
||||
|
||||
```Yaml
|
||||
ranges:
|
||||
- { begin: 192.168.222.50, end: 192.168.222.99 }
|
||||
- { begin: 192.168.222.110, end: 192.168.222.127 }
|
||||
```
|
||||
|
||||
### Host declarations
|
||||
|
||||
You can specify hosts that should get a fixed IP address based on their MAC by setting the `dhcp_hosts` option. This is a list of dicts with the following three keys, of which `name` and `mac` are mandatory:
|
||||
|
||||
| Option | Comment |
|
||||
| :--- | :--- |
|
||||
| `name` | The name of the host |
|
||||
| `mac` | The MAC address of the host |
|
||||
| `ip` | The IP address to be assigned to the host |
|
||||
|
||||
```Yaml
|
||||
dhcp_hosts:
|
||||
- name: cl1
|
||||
mac: '00:11:22:33:44:55'
|
||||
ip: 192.168.222.150
|
||||
- name: cl2
|
||||
mac: '00:de:ad:be:ef:00'
|
||||
ip: 192.168.222.151
|
||||
```
|
||||
|
||||
### Specify PXEBoot server
|
||||
|
||||
Setting the variable `dhcp_pxeboot_server`, will redirect PXE clients to the specified PXEBoot server in order to boot over the network. The specified server should have boot images on the expected locations. Use e.g. [bertvv.pxeserver](https://galaxy.ansible.com/bertvv/pxeserver) to configure it.
|
||||
|
||||
## Dependencies
|
||||
|
||||
No dependencies.
|
||||
|
||||
## Example Playbook
|
||||
|
||||
See the [test playbook](https://github.com/bertvv/ansible-role-dhcp/blob/vagrant-tests/test.yml)
|
||||
|
||||
## Testing
|
||||
|
||||
Tests for this role are provided in the form of a Vagrant environment that is kept in a separate branch, `vagrant-tests`. For more information about setting up the test environment and running the tests, refer to the [README](https://github.com/bertvv/ansible-role-dhcp/blob/vagrant-tests/README.md) of the test branch.
|
||||
|
||||
## License
|
||||
|
||||
BSD
|
||||
|
||||
## Contributing
|
||||
|
||||
Issues, feature requests, ideas are appreciated and can be posted in the Issues section. Pull requests are also very welcome. Preferably, create a topic branch and when submitting, squash your commits into one (with a descriptive message).
|
||||
5
roles/sage905.dhcp/defaults/main.yml
Normal file
5
roles/sage905.dhcp/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
# roles/dhcp/defaults/main.yml
|
||||
---
|
||||
dhcp_global_includes_missing: false
|
||||
dhcp_packages_state: "present"
|
||||
dhcp_subnets: []
|
||||
7
roles/sage905.dhcp/handlers/main.yml
Normal file
7
roles/sage905.dhcp/handlers/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
# roles/dhcp/handlers/main.yml
|
||||
---
|
||||
|
||||
- name: restart dhcp
|
||||
service:
|
||||
name: "{{ dhcp_service }}"
|
||||
state: "{{ (dhcp_global_server_state | default('started') == 'started') | ternary('restarted', 'stopped') }}"
|
||||
2
roles/sage905.dhcp/meta/.galaxy_install_info
Normal file
2
roles/sage905.dhcp/meta/.galaxy_install_info
Normal file
@@ -0,0 +1,2 @@
|
||||
install_date: Sun Jun 28 14:49:12 2020
|
||||
version: v3.0.1
|
||||
17
roles/sage905.dhcp/meta/main.yml
Normal file
17
roles/sage905.dhcp/meta/main.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author:
|
||||
description: Ansible role for setting up ISC DHCPD.
|
||||
license: BSD
|
||||
min_ansible_version: 2.9
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
- name: Fedora
|
||||
versions:
|
||||
- 29
|
||||
galaxy_tags:
|
||||
- system
|
||||
- networking
|
||||
dependencies: []
|
||||
50
roles/sage905.dhcp/tasks/main.yml
Normal file
50
roles/sage905.dhcp/tasks/main.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
# roles/dhcp/tasks/main.yml
|
||||
---
|
||||
|
||||
- name: Load distro-specific variables
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
- "{{ default }}.yml"
|
||||
tags: dhcp
|
||||
|
||||
- name: Install packages
|
||||
package:
|
||||
name: "{{ dhcp_packages }}"
|
||||
state: "{{ dhcp_packages_state }}"
|
||||
tags: dhcp
|
||||
|
||||
- name: Install includes
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ dhcp_config_dir }}/{{ item | basename }}"
|
||||
with_items: "{{ dhcp_global_includes }}"
|
||||
when: dhcp_global_includes is defined
|
||||
ignore_errors: "{{ dhcp_global_includes_missing }}"
|
||||
tags: dhcp
|
||||
|
||||
- name: Set config directory perms
|
||||
file:
|
||||
path: "{{ dhcp_config | dirname }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
tags: dhcp
|
||||
|
||||
- name: Install config file
|
||||
template:
|
||||
src: etc_dhcp_dhcpd.conf.j2
|
||||
dest: "{{ dhcp_config }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
validate: 'dhcpd -t -cf %s'
|
||||
notify: restart dhcp
|
||||
tags: dhcp
|
||||
|
||||
- name: "Ensure service is {{ dhcp_global_server_state | default('started') }}"
|
||||
service:
|
||||
name: "{{ dhcp_service }}"
|
||||
state: "{{ dhcp_global_server_state | default('started') }}"
|
||||
enabled: true
|
||||
tags: dhcp
|
||||
296
roles/sage905.dhcp/templates/etc_dhcp_dhcpd.conf.j2
Normal file
296
roles/sage905.dhcp/templates/etc_dhcp_dhcpd.conf.j2
Normal file
@@ -0,0 +1,296 @@
|
||||
# ISC DHCPD configuration -- don't edit manually!
|
||||
#
|
||||
# {{ ansible_managed }}
|
||||
|
||||
#
|
||||
# Global options
|
||||
#
|
||||
{% if dhcp_global_omapi_port is defined %}
|
||||
omapi-port {{ dhcp_global_omapi_port }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_omapi_secret is defined %}
|
||||
key omapi_key {
|
||||
algorithm HMAC-MD5;
|
||||
secret "{{ dhcp_global_omapi_secret }}";
|
||||
};
|
||||
{% endif %}
|
||||
{% if dhcp_global_authoritative is defined %}
|
||||
{{ dhcp_global_authoritative }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_log_facility is defined %}
|
||||
log-facility {{ dhcp_global_log_facility }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_bootp is defined %}
|
||||
{{ dhcp_global_bootp }} bootp;
|
||||
{% endif %}
|
||||
{% if dhcp_global_booting is defined %}
|
||||
{{ dhcp_global_booting }} booting;
|
||||
{% endif %}
|
||||
{% if dhcp_global_next_server is defined %}
|
||||
next-server {{ dhcp_global_next_server}};
|
||||
{% endif %}
|
||||
{% if dhcp_global_filename is defined %}
|
||||
filename "{{ dhcp_global_filename }}";
|
||||
{% endif %}
|
||||
{% if dhcp_global_default_lease_time is defined %}
|
||||
default-lease-time {{ dhcp_global_default_lease_time }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_max_lease_time is defined %}
|
||||
max-lease-time {{ dhcp_global_max_lease_time }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_subnet_mask is defined %}
|
||||
option subnet-mask {{ dhcp_global_subnet_mask }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_broadcast_address is defined %}
|
||||
option broadcast-address {{ dhcp_global_broadcast_address }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_routers is defined %}
|
||||
option routers {{ dhcp_global_routers }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_domain_name is defined %}
|
||||
option domain-name "{{ dhcp_global_domain_name }}";
|
||||
{% endif %}
|
||||
{% if dhcp_global_ntp_servers is defined %}
|
||||
{% if dhcp_global_ntp_servers is string %}
|
||||
option ntp-servers {{ dhcp_global_ntp_servers }};
|
||||
{% else %}
|
||||
option ntp-servers {{ dhcp_global_ntp_servers|join(', ') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if dhcp_global_domain_name_servers is defined %}
|
||||
{% if dhcp_global_domain_name_servers is string %}
|
||||
option domain-name-servers {{ dhcp_global_domain_name_servers }};
|
||||
{% else %}
|
||||
option domain-name-servers {{ dhcp_global_domain_name_servers|join(', ') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if dhcp_global_domain_search is defined %}
|
||||
{% if dhcp_global_domain_search is string %}
|
||||
option domain-search "{{ dhcp_global_domain_search }}";
|
||||
{% else %}
|
||||
option domain-search "{{ dhcp_global_domain_search|join('", "') }}";
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if dhcp_global_server_name is defined %}
|
||||
option server-name "{{ dhcp_global_server_name }}";
|
||||
{% endif %}
|
||||
{% if dhcp_global_other_options is defined %}
|
||||
{% for option in dhcp_global_other_options %}
|
||||
option {{ option }};
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover_peer is defined %}
|
||||
|
||||
#
|
||||
# DHCP Failover config
|
||||
#
|
||||
# Notes: In the past couple years, TCP ports 647 (primary) and 847 (peer) have
|
||||
# emerged as the standard bindings for DHCP dhcp_global_failover It is worth noting that as
|
||||
# recently as 2005, the dhcpd.conf(5) man page used ports 519 and 520 in its
|
||||
# failover example, but 647 and 847 look like good choices as of 2008. However,
|
||||
# the dhcpd.conf(5) man page says that the primary port and the peer port may be
|
||||
# the same number.
|
||||
|
||||
failover peer "{{ dhcp_global_failover_peer }}" {
|
||||
{% if dhcp_global_failover.role is defined %}
|
||||
# [ primary | secondary ];
|
||||
{{ dhcp_global_failover.role }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.address is defined %}
|
||||
address {{ dhcp_global_failover.address }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.port is defined %}
|
||||
port {{ dhcp_global_failover.port }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.peer_address is defined %}
|
||||
peer address {{ dhcp_global_failover.peer_address }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.peer_port is defined %}
|
||||
peer port {{ dhcp_global_failover.peer_port }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.max_response_delay is defined %}
|
||||
max-response-delay {{ dhcp_global_failover.max_response_delay }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.max_unacked_updates is defined %}
|
||||
max-unacked-updates {{ dhcp_global_failover.max_unacked_updates }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.split is defined %}
|
||||
split {{ dhcp_global_failover.split }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.hba is defined %}
|
||||
hba {{ dhcp_global_failover.hba }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.mclt is defined %}
|
||||
mclt {{ dhcp_global_failover.mclt }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.load_balance_max_seconds is defined %}
|
||||
load balance max seconds {{ dhcp_global_failover.load_balance_max_seconds }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.max_lease_misbalance is defined %}
|
||||
max-lease-misbalance {{ dhcp_global_failover.max_lease_misbalance }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.max_lease_ownership is defined %}
|
||||
max-lease-ownership {{ dhcp_global_failover.max_lease_ownership }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.min_balance is defined %}
|
||||
min-balance {{ dhcp_global_failover.min_balance }};
|
||||
{% endif %}
|
||||
{% if dhcp_global_failover.max_balance is defined %}
|
||||
max-balance {{ dhcp_global_failover.max_balance }};
|
||||
{% endif %}
|
||||
}
|
||||
{% endif %}
|
||||
{% if dhcp_global_includes is defined %}
|
||||
#
|
||||
# Includes
|
||||
#
|
||||
{% for include in dhcp_global_includes %}
|
||||
include "{{ dhcp_config_dir }}/{{ include | basename }}";
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if dhcp_global_classes is defined %}
|
||||
#
|
||||
# Classes
|
||||
#
|
||||
{% for class in dhcp_global_classes %}
|
||||
class "{{ class.name }}" {
|
||||
{% if class.match is defined %}
|
||||
{{ class.match }};
|
||||
{% endif %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
#
|
||||
# Subnet declarations
|
||||
#
|
||||
{% for subnet in dhcp_subnets %}
|
||||
subnet {{ subnet.ip }} netmask {{ subnet.netmask }} {
|
||||
{% if subnet.default_lease_time is defined %}
|
||||
default-lease-time {{ subnet.default_lease_time }};
|
||||
{% endif %}
|
||||
{% if subnet.max_lease_time is defined %}
|
||||
max-lease-time {{ subnet.max_lease_time }};
|
||||
{% endif %}
|
||||
{% if subnet.routers is defined %}
|
||||
option routers {{ subnet.routers }};
|
||||
{% endif %}
|
||||
{% if subnet.subnet_mask is defined %}
|
||||
option subnet-mask {{ subnet.subnet_mask }};
|
||||
{% endif %}
|
||||
{% if subnet.domain_search is defined %}
|
||||
{% if subnet.domain_search is string %}
|
||||
option domain-search "{{ subnet.domain_search }}";
|
||||
{% else %}
|
||||
option domain-search "{{ subnet.domain_search|join('", "') }}";
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if subnet.domain_name_servers is defined %}
|
||||
{% if subnet.domain_name_servers is string %}
|
||||
option domain-name-servers {{ subnet.domain_name_servers }};
|
||||
{% else %}
|
||||
option domain-name-servers {{ subnet.domain_name_servers|join(', ') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if subnet.range_begin is defined and subnet.range_end is defined %}
|
||||
range {{ subnet.range_begin }} {{ subnet.range_end }};
|
||||
{% endif %}
|
||||
{% if subnet.ranges is defined %}
|
||||
{% for range in subnet.ranges %}
|
||||
range {{ range.begin }} {{ range.end }};
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if subnet.server_name is defined %}
|
||||
server-name {{ subnet.server_name }};
|
||||
{% endif %}
|
||||
{% if subnet.next_server is defined %}
|
||||
next-server {{ subnet.next_server }};
|
||||
{% endif %}
|
||||
{% if subnet.filename is defined %}
|
||||
filename "{{ subnet.filename }}";
|
||||
{% endif %}
|
||||
{% if subnet.bootp is defined %}
|
||||
{{ subnet.bootp }} bootp;
|
||||
{% endif %}
|
||||
{% if subnet.booting is defined %}
|
||||
{{ subnet.booting }} booting;
|
||||
{% endif %}
|
||||
{% if subnet.hosts is defined %}
|
||||
{% for host in subnet.hosts %}
|
||||
host {{ host.name }} {
|
||||
hardware ethernet {{ host.mac }};
|
||||
fixed-address {{ host.ip }};
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if subnet.pools is defined %}
|
||||
# Address pool(s)
|
||||
{% for pool in subnet.pools %}
|
||||
pool {
|
||||
{% if pool.failover_peer is defined %}
|
||||
# This pool has failover, see above for server details
|
||||
failover peer "{{ pool.failover_peer }}";
|
||||
{% endif %}
|
||||
{% if pool.domain_name_servers is defined %}
|
||||
{% if pool.domain_name_servers is string %}
|
||||
option domain-name-servers {{ pool.domain_name_servers }};
|
||||
{% else %}
|
||||
option domain-name-servers {{ pool.domain_name_servers|join(', ') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if pool.default_lease_time is defined %}
|
||||
default-lease-time {{ pool.default_lease_time }};
|
||||
{% endif %}
|
||||
{% if pool.min_lease_time is defined %}
|
||||
min-lease-time {{ pool.min_lease_time }};
|
||||
{% endif %}
|
||||
{% if pool.max_lease_time is defined %}
|
||||
max-lease-time {{ pool.max_lease_time }};
|
||||
{% endif %}
|
||||
{% if pool.range_begin is defined and pool.range_end is defined %}
|
||||
range {{ pool.range_begin }} {{ pool.range_end }};
|
||||
{% endif %}
|
||||
{% if pool.allow is defined %}
|
||||
allow {{ pool.allow }};
|
||||
{% endif %}
|
||||
{% if pool.deny is defined %}
|
||||
deny {{ pool.deny }};
|
||||
{% endif %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% if dhcp_hosts is defined %}
|
||||
|
||||
#
|
||||
# Host declarations
|
||||
#
|
||||
{% for host in dhcp_hosts %}
|
||||
host {{ host.name | replace (" ","_") | replace ("'","_") | replace (":","_") }} {
|
||||
hardware ethernet {{ host.mac }};
|
||||
{% if host.ip is defined %}
|
||||
fixed-address {{ host.ip }};
|
||||
{% endif %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if dhcp_pxeboot_server is defined %}
|
||||
|
||||
#
|
||||
# PXEBoot server settings
|
||||
#
|
||||
option arch code 93 = unsigned integer 16; # RFC4578
|
||||
|
||||
class "pxeclients" {
|
||||
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
|
||||
next-server {{ dhcp_pxeboot_server }};
|
||||
|
||||
if option arch = 00:07 {
|
||||
filename "pxelinux/bootx64.efi";
|
||||
} else {
|
||||
filename "pxelinux/pxelinux.0";
|
||||
}
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
11
roles/sage905.dhcp/vars/RedHat.yml
Normal file
11
roles/sage905.dhcp/vars/RedHat.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
# roles/dhcp/vars/RedHat.yml
|
||||
---
|
||||
|
||||
dhcp_packages:
|
||||
- dhcp
|
||||
|
||||
dhcp_config_dir: /etc/dhcp
|
||||
|
||||
dhcp_config: /etc/dhcp/dhcpd.conf
|
||||
|
||||
dhcp_service: dhcpd
|
||||
Reference in New Issue
Block a user