aboutsummaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2018-06-05 12:01:11 +0200
committerlynxis lazus <lynxis@fe80.eu>2018-06-07 12:47:44 +0000
commit088d2d6bb705de3a0e36bfd44643f60900de8900 (patch)
treeca1d448f336c0d56e11b1e43054c2f4ce0901fab /ansible
parent4be1378a897b00db18ea8e99310db7f4c4e01b78 (diff)
ansible: udhcpd: add systemd service file
The udhcpd /etc/init.d/ script is racy and fails often. Change-Id: Ie373119a902a001f093599e289cadb8b2d290668 Fixes: OS#3311
Diffstat (limited to 'ansible')
-rw-r--r--ansible/roles/udhcpd/files/udhcpd.service13
-rw-r--r--ansible/roles/udhcpd/tasks/main.yml17
2 files changed, 30 insertions, 0 deletions
diff --git a/ansible/roles/udhcpd/files/udhcpd.service b/ansible/roles/udhcpd/files/udhcpd.service
new file mode 100644
index 0000000..03c34c1
--- /dev/null
+++ b/ansible/roles/udhcpd/files/udhcpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=udhcpcd DHCP server
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+ExecStart=/usr/sbin/udhcpd -f
+RestartSec=5
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/ansible/roles/udhcpd/tasks/main.yml b/ansible/roles/udhcpd/tasks/main.yml
index 280a5ef..e444684 100644
--- a/ansible/roles/udhcpd/tasks/main.yml
+++ b/ansible/roles/udhcpd/tasks/main.yml
@@ -12,3 +12,20 @@
template:
src: etc/udhcpd.conf
dest: /etc/udhcpd.conf
+
+- name: copy systemd unit file
+ copy:
+ src: udhcpd.service
+ dest: /lib/systemd/system/udhcpd.service
+ register: udhcpdservice
+
+- name: systemctl daemon-reload
+ systemd:
+ daemon_reload: yes
+ when: udhcpdservice | changed
+
+- name: ensure the systemd service is installed
+ systemd:
+ name: udhcpd.service
+ state: started
+ enabled: yes