From 084f2a0328143e0786cbf8ceccb1485aea5c17b6 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 2 Dec 2019 00:41:12 -0600 Subject: [PATCH 1/3] use alternate hosts file for dnsmasq --- roles/network/tasks/enable_services.yml | 6 ++++++ roles/network/tasks/main.yml | 10 +++++----- roles/network/templates/network/dnsmasq.conf.j2 | 7 +++++++ roles/network/templates/network/hosts-dnsmasq.j2 | 3 +++ 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 roles/network/templates/network/hosts-dnsmasq.j2 diff --git a/roles/network/tasks/enable_services.yml b/roles/network/tasks/enable_services.yml index 078c290c5..1e224739c 100644 --- a/roles/network/tasks/enable_services.yml +++ b/roles/network/tasks/enable_services.yml @@ -54,6 +54,12 @@ dest: /etc/dnsmasq.d/iiab.conf when: dnsmasq_install and dnsmasq_enabled and (iiab_network_mode != "Appliance") +- name: Install /etc/hosts.dnsmasq from template, sourced by /etc/dnsmasq.d/iiab.conf + template: + src: network/hosts-dnsmasq.j2 + dest: /etc/hosts.dnsmasq + when: dnsmasq_install and dnsmasq_enabled and (iiab_network_mode != "Appliance") + ## Another way to skin the cat ##- name: Check if systemd service networkd-dispatcher is enabled ## systemd: diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index a97cdab28..6a91c457e 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -49,11 +49,11 @@ # when: 'iiab_wan_iface != "none" and wan_ip != "dhcp"' ##### End static ip address info -- include_tasks: hosts.yml - tags: - - network - - hostname - - domain +#- include_tasks: hosts.yml +# tags: +# - network +# - hostname +# - domain - name: Configure wondershaper include_tasks: wondershaper.yml diff --git a/roles/network/templates/network/dnsmasq.conf.j2 b/roles/network/templates/network/dnsmasq.conf.j2 index afd148c89..edf3ae9e6 100644 --- a/roles/network/templates/network/dnsmasq.conf.j2 +++ b/roles/network/templates/network/dnsmasq.conf.j2 @@ -12,6 +12,13 @@ address=/#/{{ lan_ip }} interface={{ iiab_lan_iface }} # Set the domain for dnsmasq domain={{ iiab_domain }} +# don't use /etc/hosts +no-hosts +# instead use +addn-hosts=/etc/hosts.dnsmasq +# append 'local' to hostnames found +expand-hosts + # Specify the range of IP addresses the DHCP server will lease out to devices, and the duration of the lease dhcp-range=172.18.100.1,172.18.126.254,1h # Specify the default route diff --git a/roles/network/templates/network/hosts-dnsmasq.j2 b/roles/network/templates/network/hosts-dnsmasq.j2 new file mode 100644 index 000000000..1b5d5fe06 --- /dev/null +++ b/roles/network/templates/network/hosts-dnsmasq.j2 @@ -0,0 +1,3 @@ +# Supplied by IIAB sourced by /etc/dnsmasq.d/iiab.conf +{{ iiab_hostname }} {{ lan_ip }} +box {{ lan_ip }} From abde721ba051f33c09a23dc053a7dbf28dc72424 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 11 Dec 2019 00:54:33 -0500 Subject: [PATCH 2/3] Clarify purpose of /etc/hosts.dnsmasq --- roles/network/tasks/enable_services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/tasks/enable_services.yml b/roles/network/tasks/enable_services.yml index 1e224739c..65daf8a27 100644 --- a/roles/network/tasks/enable_services.yml +++ b/roles/network/tasks/enable_services.yml @@ -54,7 +54,7 @@ dest: /etc/dnsmasq.d/iiab.conf when: dnsmasq_install and dnsmasq_enabled and (iiab_network_mode != "Appliance") -- name: Install /etc/hosts.dnsmasq from template, sourced by /etc/dnsmasq.d/iiab.conf +- name: Install /etc/hosts.dnsmasq from template for /etc/dnsmasq.d/iiab.conf (instead of using /etc/hosts) template: src: network/hosts-dnsmasq.j2 dest: /etc/hosts.dnsmasq From c827275cc399224034ea16fb4bde799b3568dad6 Mon Sep 17 00:00:00 2001 From: A Holt Date: Wed, 11 Dec 2019 00:55:44 -0500 Subject: [PATCH 3/3] Update hosts-dnsmasq.j2 --- roles/network/templates/network/hosts-dnsmasq.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/network/templates/network/hosts-dnsmasq.j2 b/roles/network/templates/network/hosts-dnsmasq.j2 index 1b5d5fe06..8f5ea3e45 100644 --- a/roles/network/templates/network/hosts-dnsmasq.j2 +++ b/roles/network/templates/network/hosts-dnsmasq.j2 @@ -1,3 +1,3 @@ # Supplied by IIAB sourced by /etc/dnsmasq.d/iiab.conf -{{ iiab_hostname }} {{ lan_ip }} +{{ iiab_hostname }} {{ lan_ip }} box {{ lan_ip }}