From 1f5085bbfd06e618aa646a6cc85785c893ad9b30 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Wed, 9 Dec 2015 11:08:22 +0100 Subject: [PATCH] Fix dhcp range for static inventory For static inventory, we need to define dhcp range, but we need to provide the static flag. If we don't add the flag, and there are more NICs attached to that network, dnsmasq will continue providing dynamic ips on that range, causing the nodes expecting this one to fail because the ip is already assigned. Also, set the lease time to infinite, as we have static assignment on that case, so no need to renew. Change-Id: I6c0e5a3974900a4e71608e7e6c2c3fcfd1c69463 --- playbooks/roles/bifrost-ironic-install/README.md | 11 +++++++++-- .../roles/bifrost-ironic-install/defaults/main.yml | 1 + .../bifrost-ironic-install/templates/dnsmasq.conf.j2 | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/playbooks/roles/bifrost-ironic-install/README.md b/playbooks/roles/bifrost-ironic-install/README.md index 35a2b3895..67bc611c4 100644 --- a/playbooks/roles/bifrost-ironic-install/README.md +++ b/playbooks/roles/bifrost-ironic-install/README.md @@ -67,8 +67,15 @@ 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 -being ignored and the ``ipv4_address`` setting being bound to the first -listed MAC address for the node. +only being used to define the range of valid ips to be accepted, and the +``ipv4_address`` setting being bound to the first listed MAC address for +the node. +If you choose to use the static DHCP assignments, you may need to set +the ``dhcp_static_mask`` setting according to your needs. It defaults to +a /24 range. +In the case of static inventory, please also consider to set the +``dhcp_lease_time`` setting to infinite, to avoid unnecessary refreshes +of ips. In case your HW needs a kernel option to boot, set the following variable: diff --git a/playbooks/roles/bifrost-ironic-install/defaults/main.yml b/playbooks/roles/bifrost-ironic-install/defaults/main.yml index c9edfc9cc..770c31d74 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/main.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/main.yml @@ -56,6 +56,7 @@ enabled_drivers: "agent_ipmitool,pxe_amt,agent_ilo,agent_ucs" dhcp_pool_start: 192.168.1.200 dhcp_pool_end: 192.168.1.250 dhcp_lease_time: 12h +dhcp_static_mask: 255.255.255.0 # 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 62e52386f..96656bad3 100644 --- a/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 +++ b/playbooks/roles/bifrost-ironic-install/templates/dnsmasq.conf.j2 @@ -156,6 +156,8 @@ dhcp-hostsfile=/etc/dnsmasq.d/bifrost.dhcp-hosts.d # service. {% if testing %} dhcp-range=192.168.122.2,192.168.122.254,12h +{% elif inventory_dhcp %} +dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},static,{{dhcp_static_mask}},{{dhcp_lease_time}} {% else %} dhcp-range={{dhcp_pool_start}},{{dhcp_pool_end}},{{dhcp_lease_time}} {% endif %}