ansible/roles/dhcp/tasks/main.yml

71 lines
1.7 KiB
YAML
Raw Normal View History

2021-02-27 08:42:15 -06:00
# roles/dhcp/tasks/main.yml
---
- name: Load distro-specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "{{ default }}.yml"
tags: dhcp
- name: Install packages
package:
name: "{{ dhcp_packages }}"
state: "{{ dhcp_packages_state }}"
tags: dhcp
- include_tasks: apparmor-fix.yml
when: ansible_os_family == 'Debian' and dhcp_apparmor_fix|bool
tags: dhcp
- include_tasks: default-fix.yml
when: ansible_os_family == 'Debian'
tags: dhcp
- name: Install custom includes
template:
src: "{{ item }}"
dest: "{{ dhcp_config_dir }}/{{ ( item | basename ).split('.j2')[0] }}"
owner: root
group: root
mode: 0644
with_items: "{{ dhcp_custom_includes }}"
when: dhcp_custom_includes is defined
notify: restart dhcp
tags: dhcp
- name: Install includes
copy:
src: "{{ item }}"
dest: "{{ dhcp_config_dir }}/{{ item | basename }}"
with_items: "{{ dhcp_global_includes }}"
when: dhcp_global_includes is defined
ignore_errors: "{{ dhcp_global_includes_missing }}"
tags: dhcp
- name: Set config directory perms
file:
path: "{{ dhcp_config | dirname }}"
state: directory
mode: 0755
tags: dhcp
- name: Install config file
template:
src: etc_dhcp_dhcpd.conf.j2
dest: "{{ dhcp_config }}"
owner: root
group: root
mode: 0644
validate: 'dhcpd -t -cf %s'
notify: restart dhcp
tags: dhcp
- name: "Ensure service is {{ dhcp_global_server_state | default('started') }}"
service:
name: "{{ dhcp_service }}"
state: "{{ dhcp_global_server_state | default('started') }}"
enabled: true
tags: dhcp