Skip to content

Commit

Permalink
Switch to dhcpd.conf.d
Browse files Browse the repository at this point in the history
This commit adds dhcpd.conf.d as a directory for containing
configuration file fragments.  This permits the dhcpd instance to be
configured almost entirely by the sg-dhcp role, but for additional
assets such as a file containing MAC addresses to be 'dropped in'.  A
script is also provided in /usr/local/sbin/dhcpd-reconf which will
reconfigure the dhcpd server and restart it.
  • Loading branch information
the-maldridge committed Mar 27, 2017
1 parent 21b5477 commit 383e298
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
12 changes: 12 additions & 0 deletions files/dhcpd-reconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh


# This assembles all of the snippets into a complete configuration file
cat /etc/dhcpd.conf.d/* > /etc/dhcpd.conf

# Restart dhcpd iff the new config file checks out
if dhcpd -n ; then
/etc/rc.d/dhcpd restart
else
printf "Refusing to restart dhcpd: dhcpd.conf contains errors!\n"
fi
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
- name: dhcpd
command: /etc/rc.d/dhcpd restart
command: /usr/local/sbin/dhcpd-reconf
20 changes: 18 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
---
- name: Configure dhcpd
- name: Create dhcpd.conf.d
file:
path: /etc/dhcpd.conf.d
state: directory
owner: root
group: wheel
mode: 0755

- name: Configure dhcpd core
template:
src: dhcpd.conf.j2
dest: /etc/dhcpd.conf
dest: /etc/dhcpd.conf.d/10-core
owner: root
group: wheel
mode: 0644
Expand All @@ -18,3 +26,11 @@
mode: 0644
notify:
- rc.conf.local

- name: Install dhcpd-reconf
copy:
src: dhcpd-reconf
dest: /usr/local/sbin/dhcpd-reconf
owner: root
group: wheel
mode: 0755

0 comments on commit 383e298

Please sign in to comment.