--- # tasks file for dhcp - name: Assertions assert: that: - ansible_os_family in dhcp_service - ansible_os_family in dhcp_user - ansible_os_family in aliases_file - ansible_os_family in dhcp_conf_file - dhcp_config is defined - name: APT install when: ansible_pkg_mgr == 'apt' apt: name: isc-dhcp-server state: present update_cache: yes cache_valid_time: 3600 - name: Add mail alias when: dhcp_mail_alias is defined lineinfile: dest: '{{ aliases_file[ansible_os_family] }}' create: yes line: '{{ dhcp_user[ansible_os_family] }}: {{ dhcp_mail_alias }}' regexp: '{{ dhcp_user[ansible_os_family] }}:' notify: - Update SMTPd database - name: Copy configuration copy: content: '{{ dhcp_config }}' dest: '{{ dhcp_conf_file[ansible_os_family] }}' owner: root group: 0 mode: 0o0644 notify: - Restart ISC DHCP server - name: Validate config when: ansible_os_family in dhcp_conf_validate command: '{{ dhcp_conf_validate[ansible_os_family] }}' changed_when: False - name: Enable service service: name: '{{ dhcp_service[ansible_os_family] }}' state: running enabled: yes - meta: flush_handlers - name: Wait for service to come online when: ansible_os_family == 'Debian' wait_for: path: /var/run/dhcp-server/dhcpd.pid