Uploaded image for project: 'OpenStack as Infra'
  1. OpenStack as Infra
  2. OSASINFRA-3749

Configure dnsmasq on the QE setups' hypervisors to resolve HyperShift domains

XMLWordPrintable

    • Icon: Story Story
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • None
    • None
    • Converge Plat. CI Sprint 269

      Re-use the already existing role https://github.com/shiftstack/shiftstack-qa/tree/main/collection/tools/roles/tools_cifmw_dnsmasq to fill the requirement:

      #!/bin/bash
      set -e  # Exit on error
      
      ### Configuration Variables ###
      APPS_OSTEST_IP="10.46.44.164"  # IP for *.apps.ostest.shiftstack.local
      APPS_HYPERSHIFT_IP="10.46.44.167"  # IP for *.apps.shiftstack-hcp.hypershift.lab
      SERVER_IP=$(ip -4 -o addr show dev external | awk '{print $4}' | cut -d/ -f1)  # Detect the external IP
      
      echo "πŸ” Verifying existing services..."
      sudo ss -tulnp | grep :53 || true
      podman ps -a | grep dnsmasq || true
      sudo systemctl status dnsmasq || true
      sudo systemctl disable --now dnsmasq || true
      
      echo "πŸ“‚ Creating dnsmasq configuration..."
      mkdir -p ~/dnsmasq/logs
      cat <<EOF > ~/dnsmasq/dnsmasq.conf
      port=53
      listen-address=${SERVER_IP},127.0.0.1
      bind-interfaces
      address=/apps.ostest.shiftstack.local/${APPS_OSTEST_IP}
      address=/apps.shiftstack-hcp.hypershift.lab/${APPS_HYPERSHIFT_IP}
      resolv-file=/etc/resolv.conf
      log-queries
      log-facility=/var/log/dnsmasq/dnsmasq.log
      EOF
      chmod 644 ~/dnsmasq/dnsmasq.conf
      
      echo "πŸš€ Starting dnsmasq in Podman..."
      sudo podman run -d --name dnsmasq \
          --restart=always \
          --network=host \
          --cap-add=NET_ADMIN \
          -v ~/dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf:Z \
          -v ~/dnsmasq/logs:/var/log/dnsmasq:Z \
          docker.io/alpine sh -c "apk add --no-cache dnsmasq && dnsmasq -k"
      
      echo "βœ… Verifying dnsmasq is running..."
      sudo ss -tulnp | grep :53
      podman ps -a
      podman logs dnsmasq | tail -n 20
      
      echo "πŸ”₯ Configuring firewall..."
      sudo firewall-cmd --add-service=dns --permanent
      sudo firewall-cmd --reload
      sudo firewall-cmd --list-services
      
      echo "πŸ”Ž Testing DNS resolution..."
      nslookup apps.ostest.shiftstack.local 127.0.0.1
      dig @${SERVER_IP} apps.ostest.shiftstack.local
      
      echo "βœ… Setup complete! Configure other servers to use ${SERVER_IP} as their DNS server." 

              rlobillo RamΓ³n Lobillo
              rlobillo RamΓ³n Lobillo
              Itay Matza
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: