]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
dhcp-server: Support for `option host-name` declaration 581/head
authorDavid Galloway <dgallowa@redhat.com>
Fri, 17 Jul 2020 16:57:37 +0000 (12:57 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Fri, 17 Jul 2020 16:59:21 +0000 (12:59 -0400)
Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/dhcp-server/README.rst
roles/dhcp-server/templates/dhcpd.subnet.conf.j2

index 6cd3fc837be4a201c88e47ca673f0afcb13afd35..a3f676275a03c7a1beb165daa0b895c18c74443c 100644 (file)
@@ -94,6 +94,8 @@ This role basically has two required and two optional variables:
 |    - 5.6.7.8                                                        |                                                                                                                                                                                                                                                                  |
 |                                                                     |                                                                                                                                                                                                                                                                  |
 +---------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+| ``dhcp_option_hostname: False``                                     | Should this host get ``option host-name "{{ ansible_host }}";`` defined in its host declaration?  Defaults to False.  Override in secrets repo per host/group.                                                                                                   |
++---------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 
 .. _docs: https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable
 .. _dhcpd: https://linux.die.net/man/8/dhcpd
index 331eca029ccb59ee0202af8f83f4792d14d18e81..2d93039c86ba12f1c2a189161060f170c3404baa 100644 (file)
@@ -66,6 +66,9 @@ subnet {{ subnet_item.cidr | ipaddr('network') }} netmask {{ subnet_item.cidr |
     {% endif -%}
     hardware ethernet {{ hostvars[host][subnet_item.macvar] }};
     fixed-address {{ hostvars[host][subnet_item.ipvar] }};
+  {% if hostvars[host]['dhcp_option_hostname'] is defined and hostvars[host]['dhcp_option_hostname'] == true %}
+  option host-name "{{ host.split('.')[0] }}";
+  {% endif -%}
   }
   {% endif -%}
   {% endif -%}