Add OS variant configuration

- Debian 11 has a different TFTP path than Ubuntu 18.04

Add EFI PXE boot support with conditional

- Conditionally provide different file depending on BIOS or EFI boot
  (unsupported on BSD dhcpd implementations)

Fix galaxy metadata

Change-Id: If13d18dbf0455f8e9b27054da6f0eabbb602b71f
diff --git a/README.md b/README.md
index 289c0d6..0f8b19d 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,14 @@
 
 - If `routers` is not set in the `subnet` dictionary (within `dhcpd_subnets`),
   then the first usable address is set as the router.
+
 - If `routers` is set and has a list of IP addresses as a part of the
   `rfc3442routes` key, RFC3442 classless static routes (option 121) will be
   added in addition to the standard `routers` (option 3)
 
+Supports using PXE to load both traditional BIOS and EFI payloads, tested
+primarily with `iPXE`.
+
 ## Configuration docs
 
 dhcpd - ISC's docs:
@@ -22,7 +26,9 @@
 
 - https://git.kernel.org/pub/scm/network/tftp/tftp-hpa.git
 
-Also supports OpenBSD dhcpd (fork of ISC) and tftpd (BSD).
+Also supports OpenBSD dhcpd (fork of ISC) and tftpd (BSD), which has some
+difference in configuration/behavior - missing conditionals, additional option
+definitions, etc.
 
 ## Reference docs
 
@@ -36,6 +42,8 @@
 
 - [RFC1350 - TFTP protocol v2](https://tools.ietf.org/html/rfc1350)
 
+[iPXE Chainloading](https://ipxe.org/howto/chainloading)
+
 ## Requirements
 
 Minimum ansible version: 2.9.5
diff --git a/defaults/main.yml b/defaults/main.yml
index cd96479..85dcc6d 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -12,8 +12,9 @@
 # subnets to serve DHCP on
 dhcpd_subnets: {}
 
-# default PXE filename
+# default PXE and EFI TFTP delivered files
 dhcpd_pxe_filename: "undionly.kpxe"
+dhcpd_efi_filename: "snponly.efi"
 
 ## tftpd config
 # files to copy to the TFTP server
diff --git a/meta/main.yml b/meta/main.yml
index f53f389..26ee268 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -6,6 +6,7 @@
 
 galaxy_info:
   role_name: dhcpd
+  namespace: onf
 
   author: Open Networking Foundation
   description: Configures a ISC-style dhcpd server and optional TFTP server
diff --git a/tasks/main.yml b/tasks/main.yml
index 80927ec..c33ddc4 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -5,7 +5,11 @@
 # SPDX-License-Identifier: Apache-2.0
 
 - name: include OS-specific vars
-  include_vars: "{{ ansible_os_family }}.yml"
+  include_vars: "{{ item }}"
+  with_first_found:
+    - "{{ ansible_distribution }}_{{ ansible_distribution_version }}.yml"
+    - "{{ ansible_distribution }}.yml"
+    - "{{ ansible_os_family }}.yml"
 
 - name: include OS-specific tasks
   include_tasks: "{{ ansible_os_family }}.yml"
diff --git a/templates/dhcpd.conf.j2 b/templates/dhcpd.conf.j2
index 56fafb5..fda60b7 100644
--- a/templates/dhcpd.conf.j2
+++ b/templates/dhcpd.conf.j2
@@ -9,8 +9,9 @@
 max-lease-time {{ subnet.max_lease_time | default("480") }};
 
 # option definitions
-{% if ansible_system == "Linux" %}
+{% if ansible_system != "OpenBSD" %}
 option rfc3442-classless-static-routes code 121 = array of integer 8;
+option client-arch code 93 = unsigned integer 16; # RFC4578
 {% endif %}
 
 {% for subnet, subdata in dhcpd_subnets.items() %}
@@ -41,7 +42,17 @@
 
 {% if subdata.tftpd_server is defined and subdata.tftpd_server %}
   # tftpd options
+{% if ansible_system == "OpenBSD" %}
   filename "{{ subdata.pxe_filename | default(dhcpd_pxe_filename) }}";
+{% else %}
+  if option client-arch = 00:07 {
+     # amd64 EFI boot
+     filename "{{ subdata.efi_filename | default(dhcpd_efi_filename) }}";
+  } else {
+     # BIOS boot
+     filename "{{ subdata.pxe_filename | default(dhcpd_pxe_filename) }}";
+  }
+{% endif %}
   next-server {{ subdata.tftpd_server }};
 
 {% endif %}
diff --git a/vars/Debian.yml b/vars/Debian.yml
index 01b6dc6..5e02c23 100644
--- a/vars/Debian.yml
+++ b/vars/Debian.yml
@@ -13,4 +13,4 @@
 
 tftpd_service: "tftpd-hpa"
 tftpd_groupname: "tftp"
-tftpd_boot_dir: "/var/lib/tftpboot"
+tftpd_boot_dir: "/srv/tftp"
diff --git a/vars/Ubuntu_18.04.yml b/vars/Ubuntu_18.04.yml
new file mode 100644
index 0000000..35abc14
--- /dev/null
+++ b/vars/Ubuntu_18.04.yml
@@ -0,0 +1,16 @@
+---
+# dhcpd vars/Ubuntu_18.04.yml
+#
+# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+#
+# NOTE: Only put platform/OS-specific variables in this file.
+# Put all other variables in the 'defaults/main.yml' file.
+
+dhcpd_service: "isc-dhcp-server"
+dhcpd_config_dir: "/etc/dhcp"
+dhcpd_groupname: "root"
+
+tftpd_service: "tftpd-hpa"
+tftpd_groupname: "tftp"
+tftpd_boot_dir: "/var/lib/tftpboot"