From 4fdd48cbabc5b34985102c214d37ba25b3d125dc Mon Sep 17 00:00:00 2001 From: Ghe Rivero Date: Tue, 24 Nov 2015 19:43:16 +0100 Subject: [PATCH] Allow to config dhcp lease time Add a new option, dhcp_lease_time, that allows to config the default lease time. The default value, 12h, is the same that was hardcoded before. Change-Id: I25c00345d098693913d12b6dc9a012c7399725da --- .../roles/bifrost-ironic-install/README.md | 4 ++++ .../bifrost-ironic-install/defaults/main.yml | 1 + .../templates/dnsmasq.conf.j2 | 18 +++++++++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/playbooks/roles/bifrost-ironic-install/README.md b/playbooks/roles/bifrost-ironic-install/README.md index 6b5b373e8..a1292da14 100644 --- a/playbooks/roles/bifrost-ironic-install/README.md +++ b/playbooks/roles/bifrost-ironic-install/README.md @@ -60,6 +60,10 @@ If you chose to utilize the dhcp server, You may wish to set default ranges: dhcp_pool_start: 192.168.1.200 dhcp_pool_end: 192.168.1.250 +And also set the default dhcp address lease time: + +dhcp_lease_time: 12h + Alternatively, a user can choose to perform static DHCP assignments to nodes. This can be enabled by setting the ``inventory_dhcp`` setting to ``true``. This will result in the ``dhcp_pool_start`` and ``dhcp_pool_end`` settings diff --git a/playbooks/roles/bifrost-ironic-install/defaults/main.yml b/playbooks/roles/bifrost-ironic-install/defaults/main.yml index 0fb3a6832..24c3df199 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/main.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/main.yml @@ -55,6 +55,7 @@ enabled_drivers: "agent_ipmitool,pxe_amt,agent_ilo,agent_ucs" # since IP allocation will be static. dhcp_pool_start: 192.168.1.200 dhcp_pool_end: 192.168.1.250 +dhcp_lease_time: 12h # Dnsmasq default route for clients. If not defined, dnsmasq will push to clients # as default route the same IP of the dnsmasq server. # Default: undefined diff --git a/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 b/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 index 925bc96ce..54bb2ff61 100644 --- a/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 +++ b/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 @@ -158,7 +158,7 @@ dhcp-hostsfile=/etc/dnsmasq.d/bifrost.dhcp-hosts.d {% if testing %} dhcp-range=192.168.122.2,192.168.122.254,12h {% else %} -dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},12h +dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},{{dhcp_lease_time}} {% endif %} {% endif %} @@ -189,11 +189,11 @@ dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},12h #dhcp-range=1234::2, 1234::500, 64, 12h # Do Router Advertisements, BUT NOT DHCP for this subnet. -#dhcp-range=1234::, ra-only +#dhcp-range=1234::, ra-only # Do Router Advertisements, BUT NOT DHCP for this subnet, also try and -# add names to the DNS for the IPv6 address of SLAAC-configured dual-stack -# hosts. Use the DHCPv4 lease to derive the name, network segment and +# add names to the DNS for the IPv6 address of SLAAC-configured dual-stack +# hosts. Use the DHCPv4 lease to derive the name, network segment and # MAC address and assume that the host will also have an # IPv6 address calculated using the SLAAC alogrithm. #dhcp-range=1234::, ra-names @@ -216,9 +216,9 @@ dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},12h #dhcp-range=1234::, ra-stateless, ra-names # Do router advertisements for all subnets where we're doing DHCPv6 -# Unless overriden by ra-stateless, ra-names, et al, the router +# Unless overriden by ra-stateless, ra-names, et al, the router # advertisements will have the M and O bits set, so that the clients -# get addresses and configuration from DHCPv6, and the A bit reset, so the +# get addresses and configuration from DHCPv6, and the A bit reset, so the # clients don't use SLAAC addresses. #enable-ra @@ -284,11 +284,11 @@ dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},12h # any machine with Ethernet address starting 11:22:33: #dhcp-host=11:22:33:*:*:*,set:red -# Give a fixed IPv6 address and name to client with +# Give a fixed IPv6 address and name to client with # DUID 00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2 # Note the MAC addresses CANNOT be used to identify DHCPv6 clients. # Note also the they [] around the IPv6 address are obilgatory. -#dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5] +#dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5] # Ignore any clients which are not specified in dhcp-host lines # or /etc/ethers. Equivalent to ISC "deny unknown-clients". @@ -346,7 +346,7 @@ dhcp-option=3,{{dnsmasq_router}} # Send DHCPv6 option. Note [] around IPv6 addresses. #dhcp-option=option6:dns-server,[1234::77],[1234::88] -# Send DHCPv6 option for namservers as the machine running +# Send DHCPv6 option for namservers as the machine running # dnsmasq and another. #dhcp-option=option6:dns-server,[::],[1234::88]