---
- name: Install dnsmasq
  ansible.builtin.dnf:
    name: dnsmasq
    state: present

- name: Deploy dnsmasq config
  ansible.builtin.template:
    src: dnsmasq.conf.j2
    dest: /etc/dnsmasq.conf
    mode: '0644'
  notify: Restart dnsmasq

- name: Deploy dnsmasq systemd override (wait for USB ethernet)
  ansible.builtin.copy:
    dest: /etc/systemd/system/dnsmasq.service.d/wait-for-network.conf
    content: |
      [Unit]
      After=network-online.target
      Wants=network-online.target
    mode: '0644'
  notify: Reload systemd

- name: Enable and start dnsmasq
  ansible.builtin.systemd:
    name: dnsmasq
    enabled: true
    daemon_reload: true
    state: started
