aboutsummaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-06-14 23:24:25 +0800
committerAaron LI <aly@aaronly.me>2017-06-14 23:24:25 +0800
commitd9bfda6c292c6b90eb7ba295425a74679e6d9c13 (patch)
tree382f7400c5bde3ff3535dee66f1df7e09eb3f21a /roles
parent71250e63079886396de414981b3cd11075d83007 (diff)
downloaddebian-hpc-d9bfda6c292c6b90eb7ba295425a74679e6d9c13.tar.bz2
Add basic dnsmasq role
Diffstat (limited to 'roles')
-rw-r--r--roles/dnsmasq/handlers/main.yml7
-rw-r--r--roles/dnsmasq/tasks/main.yml18
-rw-r--r--roles/dnsmasq/templates/dnsmasq.conf.j254
3 files changed, 79 insertions, 0 deletions
diff --git a/roles/dnsmasq/handlers/main.yml b/roles/dnsmasq/handlers/main.yml
new file mode 100644
index 0000000..0a5cb71
--- /dev/null
+++ b/roles/dnsmasq/handlers/main.yml
@@ -0,0 +1,7 @@
+---
+- name: Restart dnsmasq
+ service:
+ name: dnsmasq
+ state: restarted
+
+# vim: set ft=yaml sw=2:
diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml
new file mode 100644
index 0000000..5275ed5
--- /dev/null
+++ b/roles/dnsmasq/tasks/main.yml
@@ -0,0 +1,18 @@
+---
+- name: Ensure that BIND is not installed in order to avoid conflicts with dnsmasq
+ apt:
+ name: bind9
+ state: absent
+
+- name: Install dnsmasq
+ apt:
+ name: dnsmasq
+ state: present
+
+- name: Generate the dnsmasq configuration file
+ template:
+ src: dnsmasq.conf.j2
+ dest: /etc/dnsmasq.conf
+ notify: Restart dnsmasq
+
+# vim: set ft=yaml sw=2:
diff --git a/roles/dnsmasq/templates/dnsmasq.conf.j2 b/roles/dnsmasq/templates/dnsmasq.conf.j2
new file mode 100644
index 0000000..670527e
--- /dev/null
+++ b/roles/dnsmasq/templates/dnsmasq.conf.j2
@@ -0,0 +1,54 @@
+#
+# /etc/dnsmasq.conf
+# Configuration file for dnsmasq.
+# See "dnsmasq --help" or dnsmasq(8) for details.
+#
+
+# If you want dnsmasq to listen for DHCP and DNS requests only on
+# specified interfaces (and the loopback) give the name of the
+# interface (eg eth0) here.
+# Repeat the line for more than one interface.
+interface={{ lan_if }}
+
+##
+## DHCP server
+##
+
+# Enable the integrated DHCP server, you need to supply the range
+# of addresses available for lease and optionally a lease time.
+# If you have more than one network, you will need to repeat this
+# for each network on which you want to supply DHCP service.
+dhcp-range={{ lan_dhcp_begin }},{{ lan_dhcp_end }},static,{{ lan_netmask }},infinite
+
+# Ignore any clients which are not specified in dhcp-host lines
+# or /etc/ethers. Equivalent to ISC "deny unknown-clients".
+# This relies on the special "known" tag which is set when
+# a host is matched.
+dhcp-ignore=tag:!known
+
+# Read /etc/ethers and act on the ethernet-address/IP pairs
+# found there just as if they had been given as --dhcp-host
+# options. Useful if you keep MAC-address/host mappings there
+# for other purposes.
+read-ethers
+
+# Set the NIS domain name
+dhcp-option=40,{{ cluster_name }}
+
+# Set the boot filename for netboot/PXE. You will only need
+# this is you want to boot machines over the network and you
+# will need a TFTP server; either dnsmasq's built in TFTP
+# server or an external one.
+dhcp-boot=pxelinux.0
+
+##
+## TFTP server
+##
+
+# Enable dnsmasq's built-in TFTP server
+enable-tftp
+
+# Set the root directory for files available via FTP.
+tftp-root={{ tftp_root }}
+
+# vim: set ft=conf: