]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
tools/make-dnsmasq-conf: fix up some outstanding issues 797/head
authorDan Mick <dmick@ibm.com>
Thu, 4 Dec 2025 19:31:16 +0000 (11:31 -0800)
committerDan Mick <dmick@ibm.com>
Thu, 4 Dec 2025 19:33:14 +0000 (11:33 -0800)
1) hack domain_tag calculation for pok, suggest a better approach
2) fully-qualify the ip manipulation module names
3) host-record instead of host-address
4) create host-record in canonical order to avoid anyone worrying

Signed-off-by: Dan Mick <dmick@ibm.com>
tools/make-dnsmasq-conf.yml

index 9683959bf69ca65611e0e9bf93aeac207df39f7d..5f36e3d468cd8659d7794b881e0547585fa758f2 100644 (file)
@@ -1,5 +1,5 @@
 ---
-# Generate dnsmasq dhcp-host and host-address lines from inventory.
+# Generate dnsmasq dhcp-host and host-record lines from inventory.
 # (note the top-level play definitions with subtasks.)
 #
 # Run with --limit set appropriately, for example,
           boot_mac: "{{ hostvars[inventory_hostname][maas_boot_mac_var] }}"
           domain: "{{ inventory_hostname | regex_replace('^[^.]+\\.', '') }}"
           shortname: "{{ inventory_hostname | regex_replace('\\..*', '') }}"
-          domain_tag: "{{ inventory_hostname.split('.')[1:-4] | join('-') }}"
+          # for tucson, ignore the last 4; for pok, the last 3
+          # maybe an algorithm: have a "top-level lab domain" var,
+          # ceph.tuc.ibm.com or sepia.ceph.com, and remove it, then sub
+          # . to -
+          # domain_tag: "{{ inventory_hostname.split('.')[1:-4] | join('-') }}"
+          domain_tag: "{{ inventory_hostname.split('.')[1:-3] | join('-') }}"
       tags: always
 
 
           {% endfor %}
           {% for host in ansible_play_hosts %}
           {% set data = hostvars[host]['myvars'] %}
-          host-address={{ data.bmc_ip }},{{ data.shortname }}.{{ ipmi_domain }}
+          host-record={{ data.shortname }}.{{ ipmi_domain }},{{ data.bmc_ip }}
           {% endfor %}
           {% for vlan in maas_networking[0]['vlans'] %}
           {% set data = hostvars[ansible_play_hosts[0]].myvars %}
           {% for subnet in vlan['subnets'] %}
           {% if data.bmc_ip | ansible.utils.ipaddr(subnet.cidr) %}
-          dhcp-range={{ subnet.gateway | ipmath(5) }},static,{{ subnet.cidr | ipaddr("netmask") }},{{ subnet.cidr | ipaddr("broadcast") }}
+          dhcp-range={{ subnet.gateway | ansible.utils.ipmath(5) }},static,{{ subnet.cidr | ansible.utils.ipaddr("netmask") }},{{ subnet.cidr | ansible.utils.ipaddr("broadcast") }}
           dhcp-option=tag:ipmi,option:router,{{ subnet.gateway }}
           {% endif %}
           {% endfor %}
       delegate_to: localhost
       run_once: true
 
-
     # maas_networking variable:
     # maas_networking['tucson-qe']['vlans'][]['subnets'][]['cidr']
 
     # loop across hosts_by_domain_tag, create a file named with 'domain_tag',
-    # add dhcp-host and host-address stanzas
+    # add dhcp-host and host-record stanzas
     - name: "build domain_tag dnsmasq conf part files"
       copy:
         dest: "../dnsmasq.conf/{{ domain_tag | replace('-', '.') }}.conf"
         content: |
-          {% set domain = domain_tag | replace('-', '.') + '.ceph.tuc.ibm.com' %}
+          {% set domain = domain_tag | replace('-', '.') + '.' + ipmi_domain %}
           ###
           ### {{ domain }}
           ###
           {% endfor %}
           {% for host in hosts_by_domain_tag[domain_tag] %}
           {% set data = hostvars[host]['myvars'] %}
-          host-address={{ data.boot_ip }},{{ data.fqdn }}
+          host-record={{ data.fqdn }},{{ data.boot_ip }}
           {% endfor %}
           {% for vlan in maas_networking[0]['vlans'] %}
           {% for subnet in vlan['subnets'] %}
           {% if domain == subnet.domain %}
-          dhcp-range={{ subnet.gateway | ipmath(5) }},static,{{ subnet.cidr | ipaddr("netmask") }},{{ subnet.cidr | ipaddr("broadcast") }}
+          dhcp-range={{ subnet.gateway | ansible.utils.ipmath(5) }},static,{{ subnet.cidr | ansible.utils.ipaddr("netmask") }},{{ subnet.cidr | ansible.utils.ipaddr("broadcast") }}
           dhcp-option=tag:{{ domain_tag }},option:router,{{ subnet.gateway }}
           {% endif %}
           {% endfor %}