---
- name: Configure inetd service and uncomment tftp lines
  hosts: all
  gather_facts: no
  tasks:
    - name: Enable inetd in /etc/rc.conf
      lineinfile:
        path: /etc/rc.conf
        line: 'inetd_enable="YES"'
        create: yes
        state: present
      become: yes

    - name: Uncomment tftp lines in /etc/inetd.conf
      lineinfile:
        path: /etc/inetd.conf
        regexp: '^#\s*(tftp.*)'
        line: '\1'
        backrefs: yes
        state: present
      become: yes
      with_items: # I don't like that but it works...
        - 'tftp'
        - 'tftp'

    - name: Create /tftpboot directory
      file:
        path: /tftpboot
        state: directory
        owner: root
        group: wheel
        mode: '0755'
      become: yes

    - name: Restart inetd service
      service:
        name: inetd
        state: restarted
      become: yes
