Skip to content

Commit

Permalink
add handler for dhcp restart
Browse files Browse the repository at this point in the history
  • Loading branch information
iljarotar committed Dec 5, 2024
1 parent cc4fea6 commit 7d83ee0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 14 additions & 0 deletions partition/roles/dhcp/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: restart dhcp server
service:
name: "{{ dhcp_service_name }}"
enabled: true
state: restarted
daemon-reload: true

- name: ensure dhcp server is running
service:
name: "{{ dhcp_service_name }}"
enabled: true
state: started
listen: restart dhcp server
20 changes: 3 additions & 17 deletions partition/roles/dhcp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,23 @@
template:
src: dhcpd.conf.j2
dest: /etc/dhcp/dhcpd.conf
register: _dhcpd_conf
notify: restart dhcp server

- name: render isc-dhcp-server config
template:
src: isc-dhcp-server.j2
dest: /etc/default/isc-dhcp-server
register: _isc_dhcp_server
notify: restart dhcp server

- name: render static hosts config
template:
src: dhcpd.hosts.j2
dest: /etc/dhcp/dhcpd.hosts
when: dhcp_static_hosts is defined
register: _hosts_conf
notify: restart dhcp server

- name: install isc-dhcp-server
apt:
name:
- isc-dhcp-server
update_cache : yes

- name: restart isc-dhcp-server on config change
service:
name: "{{ dhcp_service_name }}"
enabled: true
state: restarted
daemon-reload: true
when: _dhcpd_conf is changed or _isc_dhcp_server is changed or _hosts_conf is changed

- name: ensure isc-dhcp-server is running
service:
name: "{{ dhcp_service_name }}"
enabled: true
state: started

0 comments on commit 7d83ee0

Please sign in to comment.