---
- name: udhcpd | update apt-cache
  apt:
    cache_valid_time: 3600
    update_cache: yes

- name: udhcpd | install
  apt:
    name: udhcpd

- name: configure udhcpd
  template:
    src: etc/udhcpd.conf
    dest: /etc/udhcpd.conf

- name: copy systemd unit file
  copy:
    src: udhcpd.service
    dest: /lib/systemd/system/udhcpd.service
  register: udhcpdservice

- name: systemctl daemon-reload
  systemd:
    daemon_reload: yes
  when: udhcpdservice is changed

- name: ensure the systemd service is installed
  systemd:
    name: udhcpd.service
    state: started
    enabled: yes