]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
dhcp-server: Only create host declaration if its IP is in subnet we're writing 558/head
authorDavid Galloway <dgallowa@redhat.com>
Thu, 2 Apr 2020 15:25:03 +0000 (11:25 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Thu, 2 Apr 2020 17:03:17 +0000 (13:03 -0400)
In the Octo lab, we have multiple subnets with the same domain and VLAN.  This is problematic because in the `dhcp_subnets` dict, we only anticipate there being one cidr.

This change will let you have multiple "subnets" in `dhcp_subnets` without fiddling with the ansible inventory ipvars or macvars.

Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/dhcp-server/templates/dhcpd.subnet.conf.j2

index c99a9d400a61fe49d2eccf43356a4006281d0e88..331eca029ccb59ee0202af8f83f4792d14d18e81 100644 (file)
@@ -55,6 +55,7 @@ subnet {{ subnet_item.cidr | ipaddr('network') }} netmask {{ subnet_item.cidr |
 
   {% for host in groups['all'] | sort | unique -%}
   {% if hostvars[host][subnet_item.macvar] is defined -%}
+  {% if hostvars[host][subnet_item.ipvar] | ipaddr(subnet_item.cidr) | ipaddr('bool') -%}
   host {{ host.split('.')[0] }}-{{ subnet }} {
     {% if hostvars[host]['dhcp_next_server'] is defined -%}
     next-server {{ hostvars[host]['dhcp_next_server'] }};
@@ -67,6 +68,7 @@ subnet {{ subnet_item.cidr | ipaddr('network') }} netmask {{ subnet_item.cidr |
     fixed-address {{ hostvars[host][subnet_item.ipvar] }};
   }
   {% endif -%}
+  {% endif -%}
   {% endfor -%}
 } # end subnet
 {% endif %}