fix: dhcpd ipv4 service
This commit is contained in:
parent
e209a93a78
commit
a6878c0b7d
@ -1,4 +1,8 @@
|
||||
---
|
||||
- name: Reload systemd
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Restart dhcpd
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ dhcpd_service }}"
|
||||
|
||||
@ -39,8 +39,43 @@
|
||||
when: ansible_facts['os_family'] | lower == 'debian'
|
||||
notify: Restart dhcpd
|
||||
|
||||
- name: Deploy dhcpd4@ systemd template unit (Arch)
|
||||
ansible.builtin.template:
|
||||
src: dhcpd4@.service.j2
|
||||
dest: /usr/lib/systemd/system/dhcpd4@.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: ansible_facts['os_family'] == 'Archlinux'
|
||||
notify:
|
||||
- Reload systemd
|
||||
- Restart dhcpd
|
||||
|
||||
- name: Disable generic dhcpd4.service (Arch)
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ dhcpd_service_generic }}"
|
||||
enabled: false
|
||||
state: stopped
|
||||
when:
|
||||
- ansible_facts['os_family'] == 'Archlinux'
|
||||
- dhcpd_service_generic is defined
|
||||
failed_when: false
|
||||
|
||||
- name: Enable and start DHCP server
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ dhcpd_service }}"
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- name: Allow DHCP traffic on {{ dhcpd_interface }}
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "67"
|
||||
proto: udp
|
||||
direction: in
|
||||
interface: "{{ dhcpd_interface }}"
|
||||
comment: "DHCP on {{ dhcpd_interface }}"
|
||||
retries: 5
|
||||
delay: 2
|
||||
register: ufw_dhcp_result
|
||||
until: ufw_dhcp_result is succeeded
|
||||
|
||||
15
roles/dhcpd/templates/dhcpd4@.service.j2
Normal file
15
roles/dhcpd/templates/dhcpd4@.service.j2
Normal file
@ -0,0 +1,15 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=IPv4 DHCP server on %I
|
||||
After=sys-subsystem-net-devices-%i.device
|
||||
BindsTo=sys-subsystem-net-devices-%i.device
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart=/usr/bin/dhcpd -4 -q -cf /etc/dhcpd.conf -pf /run/dhcpd4/dhcpd-%i.pid %I
|
||||
RuntimeDirectory=dhcpd4
|
||||
PIDFile=/run/dhcpd4/dhcpd-%i.pid
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@ -1,3 +1,4 @@
|
||||
dhcpd_package: dhcp
|
||||
dhcpd_service: dhcpd4
|
||||
dhcpd_service: "dhcpd4@{{ dhcpd_interface }}"
|
||||
dhcpd_service_generic: dhcpd4
|
||||
dhcpd_config_path: /etc/dhcpd.conf
|
||||
|
||||
Loading…
Reference in New Issue
Block a user