ricsanfre.dnsmasq

Ansible Role: dnsmasq

CI

This Ansible role helps you install and set up dnsmasq, a lightweight DHCP and DNS server, on a Linux system.

Requirements

You don't need any special requirements to use this role.

Role Variables

Here are some variables you can use, along with their default settings (see defaults\main.yaml):

  • Host interface and IP for dnsmasq:

    dnsmasq_interface: ''
    dnsmasq_listen_address: ''
    

    Default values are empty. The role will automatically find the interface and IP from the system's facts. If your server has multiple interfaces, please provide these values.

  • Local domain name:

    dnsmasq_domain_name: example.ricsanfre.com
    
  • DNS servers to use for resolving queries:

    dnsmasq_upstream_dns_servers:
      - 80.58.61.250
      - 80.58.61.254
    
  • DHCP address range:

    dnsmasq_dhcp_range: '10.0.0.32,10.0.0.128'
    

By default, dnsmasq will manage the DHCP and DNS records for hosts listed in the inventory by using the ip, mac, and hostname variables. Here's an example of how to set these up:

hosts:
  all:
    children:
      cluster:
        hosts:
          server1:
            hostname: server1
            ip: 10.0.0.11
            mac: dc:a6:32:9c:29:b9
          server2:
            hostname: server2
            ip: 10.0.0.12
            mac: e4:5f:01:2d:fd:19
          server3:
            hostname: server3
            ip: 10.0.0.13
            mac: e4:5f:01:2f:49:05

You can also add more DHCP and DNS records using these variables:

  • Additional DHCP records:

    dnsmasq_additional_dhcp_hosts: {}
    

    Example:

    dnsmasq_additional_dhcp_hosts:
      ethernet_switch:
        desc: "Ethernet Switch"
        mac: 94:a6:7e:7c:c7:69
        ip: 10.0.0.2
    
  • Additional DNS records:

    dnsmasq_additional_dns_hosts: {}
    

    Example:

    dnsmasq_additional_dns_hosts:
      ntp_server:
        desc: "NTP Server"
        hostname: ntp
        ip: 10.0.0.1
      dns_server:
        desc: "DNS Server"
        hostname: dns
        ip: 10.0.0.1
    

You can also enable the TFTP service and set its root directory:

dnsmasq_enable_tftp: false
dnsmasq_tftp_root: /srv/tftp

If you want, you can add more configuration options at the end of the dnsmasq config file:

dnsmasq_additional_conf: []

Example:

dnsmasq_additional_conf: |-
      # Enabling Netboot
      dhcp-boot=pxelinux.0
      dhcp-match=set:efi-x86_64,option:client-arch,7
      dhcp-boot=tag:efi-x86_64,bootx64.efi

Dependencies

There are no dependencies for this role.

Example Playbook

Here's how you can use this role in a playbook:

---
- name: Set up Dnsmasq
  hosts: host
  vars:
    additional_dhcp_hosts:
      ethernet_switch:
        desc: "Ethernet Switch"
        mac: 94:a6:7e:7c:c7:69
        ip: 10.0.0.2
    additional_dns_hosts:
      ntp_server:
        desc: "NTP Server"
        hostname: ntp
        ip: 10.0.0.1
      dns_server:
        desc: "DNS Server"
        hostname: dns
        ip: 10.0.0.1
  roles:
    - role: ricsanfre.dnsmasq

License

This role is available under the MIT/BSD license.

Author Information

This role was created by Ricardo Sanchez (ricsanfre).

Informazioni sul progetto

Dnsmasq installation and configuration role

Installa
ansible-galaxy install ricsanfre.dnsmasq
Licenza
mit
Download
11.1k
Proprietario
Telecom engineer.