maas-dhcp-2.0.0b3+ does not start missing dhcpd.conf dhcpd-interfaces /run/maas not writable by dhcpd
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MAAS |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Package maas-dhcp should include and configure usable default config files to allow it to start.
We have a fresh install of Ubuntu 16.04 LTS with MAAS PPA maas/next. Our first version installed was MAAS and specifically maas-dhcp-
After install, the dhcp server does not start. It seems the following items are missing, at a minimum:
1. Missing /var/lib/
$ sudo service maas-dhcpd start
$ sudo service maas-dhcpd status
● maas-dhcpd.service - MAAS instance of ISC DHCP server for IPv4
Loaded: loaded (/lib/systemd/
Active: failed (Result: exit-code) since Tue 2016-06-14 11:32:15 PDT; 4min 59s ago
Condition: start condition failed at Tue 2016-06-14 11:37:11 PDT; 3s ago
Docs: man:dhcpd(8)
Main PID: 30586 (code=exited, status=1/FAILURE)
Jun 14 11:32:15 maas systemd[1]: Starting MAAS instance of ISC DHCP server for IPv4...
Jun 14 11:32:15 maas systemd[1]: Started MAAS instance of ISC DHCP server for IPv4.
Jun 14 11:32:15 maas systemd[1]: maas-dhcpd.service: Main process exited, code=exited, status=1/FAILURE
Jun 14 11:32:15 maas systemd[1]: maas-dhcpd.service: Unit entered failed state.
Jun 14 11:32:15 maas systemd[1]: maas-dhcpd.service: Failed with result 'exit-code'.
Jun 14 11:36:08 maas systemd[1]: Stopped MAAS instance of ISC DHCP server for IPv4.
I have entered an interface name as the only content of the requested file:
$ cat /var/lib/
enp3s0
2. Missing /var/lib/
$ sudo service maas-dhcpd start
$ sudo service maas-dhcpd status
● maas-dhcpd.service - MAAS instance of ISC DHCP server for IPv4
Loaded: loaded (/lib/systemd/
Active: failed (Result: exit-code) since Tue 2016-06-14 11:32:15 PDT; 6min ago
Condition: start condition failed at Tue 2016-06-14 11:38:47 PDT; 24s ago
Docs: man:dhcpd(8)
Main PID: 30586 (code=exited, status=1/FAILURE)
Jun 14 11:32:15 maas systemd[1]: Starting MAAS instance of ISC DHCP server for IPv4...
Jun 14 11:32:15 maas systemd[1]: Started MAAS instance of ISC DHCP server for IPv4.
Jun 14 11:32:15 maas systemd[1]: maas-dhcpd.service: Main process exited, code=exited, status=1/FAILURE
Jun 14 11:32:15 maas systemd[1]: maas-dhcpd.service: Unit entered failed state.
Jun 14 11:32:15 maas systemd[1]: maas-dhcpd.service: Failed with result 'exit-code'.
Jun 14 11:36:08 maas systemd[1]: Stopped MAAS instance of ISC DHCP server for IPv4.
Using a blank dhcpd.conf, which I presume is not valid dhcpd configuration:
$ sudo touch /var/lib/
The service will not start:
$ sudo service maas-dhcpd status
● maas-dhcpd.service - MAAS instance of ISC DHCP server for IPv4
Loaded: loaded (/lib/systemd/
Active: failed (Result: exit-code) since Tue 2016-06-14 12:33:19 PDT; 2s ago
Docs: man:dhcpd(8)
Process: 3706 ExecStart=/bin/sh -ec INTERFACES=$(cat /var/lib/
Process: 3702 ExecStartPre=
Process: 3697 ExecStartPre=
Main PID: 3706 (code=exited, status=1/FAILURE)
Jun 14 12:33:18 maas systemd[1]: Starting MAAS instance of ISC DHCP server for IPv4...
Jun 14 12:33:19 maas systemd[1]: Started MAAS instance of ISC DHCP server for IPv4.
Jun 14 12:33:19 maas dhcpd[3706]: Wrote 0 leases to leases file.
Jun 14 12:33:19 maas systemd[1]: maas-dhcpd.service: Main process exited, code=exited, status=1/FAILURE
Jun 14 12:33:19 maas systemd[1]: maas-dhcpd.service: Unit entered failed state.
or more precisely it exits immediately with exit code 1. Expanding out the last line of the service file:
$ sudo dhcpd -user dhcpd -group dhcpd -f -q -4 -pf /run/maas/
$ echo $?
1
An example showing basic valid config for a range should be included in the package installed documentation. The current documentation https:/
3. /run/maas/dhcp is owned by root, but not writable by user dhcpd
Inspecting the service definition, it clearly states that the PID file will be written by user dhcpd. The directory as created by the run attempts above is owned by root, and does not have the necessary permissions for user dhcpd to write to the directory:
$ ls -al /run/maas/dhcp
total 0
drwxr-xr-x 2 root root 40 Jun 14 12:33 .
drwxr-xr-x 4 root root 80 Jun 14 12:33 ..
$ cat /lib/systemd/
[Unit]
Description=MAAS instance of ISC DHCP server for IPv4
Documentation=
Wants=network-
After=network-
After=time-
BindsTo=
ConditionPathEx
ConditionPathEx
[Service]
# Allow dhcp server to write lease and pid file as 'dhcpd' user
ExecStartPre=
# The leases files need to be root:dhcpd even when dropping privileges
ExecStartPre=
# Start the daemon
ExecStart=/bin/sh -ec '\
INTERFACES=
LEASES_
[ -e $LEASES_FILE ] || touch $LEASES_FILE; \
/usr/
chown root:dhcpd /var/lib/maas/dhcp $LEASES_FILE; \
chmod 775 /var/lib/maas/dhcp ; chmod 664 $LEASES_FILE; \
exec dhcpd -user dhcpd -group dhcpd -f -q -4 -pf /run/maas/
-cf /var/lib/
[Install]
WantedBy=
Workaround attempted, unsuccessful:
$ sudo chmod 775 /run/maas/dhcp
$ ls -al /run/maas/dhcp
total 0
drwxrwxr-x 2 root root 40 Jun 14 12:33 .
drwxr-xr-x 4 root root 80 Jun 14 12:33 ..
$ sudo service maas-dhcpd start
$ sudo service maas-dhcpd status
● maas-dhcpd.service - MAAS instance of ISC DHCP server for IPv4
Loaded: loaded (/lib/systemd/
Active: failed (Result: exit-code) since Tue 2016-06-14 12:40:45 PDT; 1s ago
Docs: man:dhcpd(8)
Process: 4132 ExecStart=/bin/sh -ec INTERFACES=$(cat /var/lib/
Process: 4128 ExecStartPre=
Process: 4125 ExecStartPre=
Main PID: 4132 (code=exited, status=1/FAILURE)
Jun 14 12:40:45 maas systemd[1]: Starting MAAS instance of ISC DHCP server for IPv4...
Jun 14 12:40:45 maas systemd[1]: Started MAAS instance of ISC DHCP server for IPv4.
Jun 14 12:40:45 maas dhcpd[4132]: Wrote 0 leases to leases file.
Jun 14 12:40:45 maas systemd[1]: maas-dhcpd.service: Main process exited, code=exited, status=1/FAILURE
Jun 14 12:40:45 maas systemd[1]: maas-dhcpd.service: Unit entered failed state.
Jun 14 12:40:45 maas systemd[1]: maas-dhcpd.service: Failed with result 'exit-code'.
Currently installed versions:
$ dpkg -l '*maas*'|cat
Desired=
| Status=
|/ Err?=(none)
||/ Name Version Architecture Description
+++-===
ii maas 2.0.0~beta7+
ii maas-cli 2.0.0~beta7+
un maas-cluster-
ii maas-common 2.0.0~beta7+
ii maas-dhcp 2.0.0~beta7+
ii maas-dns 2.0.0~beta7+
ii maas-proxy 2.0.0~beta7+
ii maas-rack-
ii maas-region-api 2.0.0~beta7+
ii maas-region-
un maas-region-
un python-django-maas <none> <none> (no description available)
un python-maas-client <none> <none> (no description available)
un python-
ii python3-django-maas 2.0.0~beta7+
ii python3-maas-client 2.0.0~beta7+
ii python3-
This is explicitly designed this way. MAAS allows you to have multiple DHCP servers managed by different rack controllers. The DHCP server can quickly be moved from one rack controller to another and MAAS will handle all of this. It will render the correct configuration on the new rack controller and remove the old configuration from the previous rack controller. This prevents administrators from starting the DHCP server when it is now being managed by another rack controller.
Also MAAS does not run a DHCP server by default so it cannot ship with a DHCP server configuration that can run. It only runs a DHCP server when you tell MAAS to turn it on.
The DHCP service also cannot be running unless rackd is running that is why maas-dhcpd is BindTo=maas-rackd. This is because the DHCP server sends notification messages to the maas-rackd process when it commits, releases, or expires a lease.
You need to configure MAAS using the API or UI to turn on the DHCP service. MAAS will then monitor that service, handle notifications, and control/ensure that service is doing what it should be doing.