Skip to content

Commit

Permalink
HOTFIX-1 (#841)
Browse files Browse the repository at this point in the history
Add subnet custom settings and fix global settings + update README
  • Loading branch information
oxedions committed Oct 20, 2023
1 parent 1eefe0a commit 506ee2c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
2 changes: 1 addition & 1 deletion collections/infrastructure/galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace: bluebanquise
name: infrastructure

# The version of the collection. Must be compatible with semantic versioning
version: 2.2.1
version: 2.3.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
32 changes: 32 additions & 0 deletions collections/infrastructure/roles/dhcp_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,37 @@ Consider increasing the default leases values once your network is production re

### Advanced usage

#### Add global options

It is possible to include as many global settings as desired using the `dhcp_server_global_settings` list.

For example:

```yaml
dhcp_server_global_settings:
- ping-check false
```

Note: do not include the `;` at the end, it is automatically added by the role.

#### Add options per subnet

It is possible to include as many per subnet settings as desired using the `dhcp_server_subnet_settings` defined under the logical network in `networks` dict.

For example:

```yaml
networks:
net-1:
subnet: 10.11.0.0
prefix: 16
dhcp_server: true
dhcp_server_subnet_settings:
- deny unknown-clients
```

Note: do not include the `;` at the end, it is automatically added by the role.

#### Multiple entries

It is possible to have multiple entries for an host interface in the
Expand Down Expand Up @@ -184,6 +215,7 @@ This allows for example to have an heterogenous cluster, with a group of hosts b

## Changelog

* 1.6.0: Added subnet custom settings. Benoit Leveugle <benoit.leveugle@gmail.com>
* 1.5.1: Fix ip and host orders. Benoit Leveugle <benoit.leveugle@gmail.com>
* 1.5.0: Update to BB 2.0 format. Benoit Leveugle <benoit.leveugle@gmail.com>
* 1.4.0: Add capability to choose ipxe ROM. Benoit Leveugle <benoit.leveugle@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
option pxelinux.reboottime code 211 = unsigned integer 32;
option architecture-type code 93 = unsigned integer 16;

{% if dhcp_server_global_settings is iterable %}
{% for setting in dhcp_server_global_settings %}
{{ setting }};
{% if dhcp_server_global_settings is defined and dhcp_server_global_settings is iterable and dhcp_server_global_settings is not string and dhcp_server_global_settings is not mapping %}
{% for global_setting in dhcp_server_global_settings %}
{{ global_setting }};
{% endfor %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,43 @@ subnet {{ networks[network]['subnet'] }} netmask {{ (networks[network]['subnet']

default-lease-time {{ dhcp_server_default_lease_time | string }};
max-lease-time {{ dhcp_server_max_lease_time | string }};
{% if networks[network]['dhcp_unknown_range'] is defined and networks[network]['dhcp_unknown_range'] is not none %}
{% if networks[network]['dhcp_unknown_range'] is defined and networks[network]['dhcp_unknown_range'] is not none %}
range {{ networks[network]['dhcp_unknown_range'] }};
{% endif %}
{% endif %}
option domain-name "{{ bb_domain_name | default(dhcp_server_domain_name) }}";
option broadcast-address {{ (networks[network]['subnet'] + '/' + (networks[network]['prefix'] | string) ) | ansible.utils.ipaddr('broadcast') }};
{% if networks[network]['gateway'] is defined %}
{% if networks[network]['gateway'] is string %}
{% if networks[network]['gateway'] is defined %}
{% if networks[network]['gateway'] is string %}
option routers {{ networks[network]['gateway'] }};
{% elif networks[network]['gateway'] is iterable and networks[network]['gateway'] is not mapping %}
{% elif networks[network]['gateway'] is iterable and networks[network]['gateway'] is not mapping %}
{{ item_add("option routers", networks[network]['gateway'], "host") }}
{% endif %}
{% endif %}
{% endif %}
{% endif %}

{# Either ~~~~~~~ ADVANCED SERVICES #}
{% if networks[network]['services'] is defined and networks[network]['services'] is iterable and networks[network]['services'] is not string and networks[network]['services'] is mapping %}
{% if networks[network]['services']['dns'] is defined %}
{% if networks[network]['services'] is defined and networks[network]['services'] is iterable and networks[network]['services'] is not string and networks[network]['services'] is mapping %}
{% if networks[network]['services']['dns'] is defined %}
{{ item_add("option domain-name-servers", networks[network]['services']['dns'], "ip") }}
{% endif %}
{% if networks[network]['services']['ntp'] is defined %}
{% endif %}
{% if networks[network]['services']['ntp'] is defined %}
{{ item_add("option ntp-servers", networks[network]['services']['ntp'], "host") }}
{% endif %}
{% if networks[network]['services']['pxe'] is defined %}
{% endif %}
{% if networks[network]['services']['pxe'] is defined %}
{{ item_add("next-server", networks[network]['services']['pxe'], "host") }}
{% endif %}
{% endif %}

{# Or ~~~~~~~ BASIC SERVICES #}
{% elif networks[network]['services_ip'] is defined and (networks[network]['services_ip'] | ansible.utils.ipaddr) %}
{% elif networks[network]['services_ip'] is defined and (networks[network]['services_ip'] | ansible.utils.ipaddr) %}
option domain-name-servers {{ networks[network]['services_ip'] }};
option ntp-servers {{ networks[network]['services_ip'] }};
next-server {{ networks[network]['services_ip'] }};
{% endif %}
{% endif %}

{% if networks[network]['dhcp_server_subnet_settings'] is defined and networks[network]['dhcp_server_subnet_settings'] is iterable and networks[network]['dhcp_server_subnet_settings'] is not string and networks[network]['dhcp_server_subnet_settings'] is not mapping %}
{% for subnet_setting in networks[network]['dhcp_server_subnet_settings'] %}
{{ subnet_setting }};
{% endfor %}
{% endif %}

include "{{ dhcp_server_conf_dir }}/dhcpd.{{ network }}.conf";

Expand Down
2 changes: 1 addition & 1 deletion collections/infrastructure/roles/dhcp_server/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
dhcp_server_role_version: 1.5.1
dhcp_server_role_version: 1.6.0

0 comments on commit 506ee2c

Please sign in to comment.