mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
Merge pull request #1779 from holta/dnsmasq-tidy-up
Fixing ./iiab-network on Ubuntu 16.04 (and other OS's possibly?)
This commit is contained in:
commit
c3242ea435
2 changed files with 58 additions and 28 deletions
|
@ -2,14 +2,14 @@
|
||||||
service:
|
service:
|
||||||
name: dhcpd
|
name: dhcpd
|
||||||
enabled: no
|
enabled: no
|
||||||
when: not dhcpd_enabled and dhcpd_install
|
when: dhcpd_install and not dhcpd_enabled
|
||||||
|
|
||||||
# service is restarted with NM dispatcher.d script
|
# service is restarted with NM dispatcher.d script
|
||||||
- name: Enable dhcpd service
|
- name: Enable dhcpd service
|
||||||
service:
|
service:
|
||||||
name: dhcpd
|
name: dhcpd
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: dhcpd_enabled and dhcpd_install
|
when: dhcpd_install and dhcpd_enabled
|
||||||
|
|
||||||
- name: Install /etc/sysconfig/dhcpd, /etc/dhcpd-iiab.conf from templates
|
- name: Install /etc/sysconfig/dhcpd, /etc/dhcpd-iiab.conf from templates
|
||||||
template:
|
template:
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
with_items:
|
with_items:
|
||||||
- { src: 'dhcp/dhcpd-env.j2', dest: '/etc/sysconfig/dhcpd', mode: '0644' }
|
- { src: 'dhcp/dhcpd-env.j2', dest: '/etc/sysconfig/dhcpd', mode: '0644' }
|
||||||
- { src: 'dhcp/dhcpd-iiab.conf.j2', dest: '/etc/dhcpd-iiab.conf', mode: '0644' }
|
- { src: 'dhcp/dhcpd-iiab.conf.j2', dest: '/etc/dhcpd-iiab.conf', mode: '0644' }
|
||||||
when: dhcpd_enabled and dhcpd_install
|
when: dhcpd_install and dhcpd_enabled
|
||||||
|
|
||||||
- name: Install /etc/named-iiab.conf and two *.zone.db files into /var/named-iiab
|
- name: Install /etc/named-iiab.conf and two *.zone.db files into /var/named-iiab
|
||||||
template:
|
template:
|
||||||
|
@ -34,34 +34,65 @@
|
||||||
- { src: 'named/named-iiab.conf.j2', dest: '/etc/named-iiab.conf', mode: '0644' }
|
- { src: 'named/named-iiab.conf.j2', dest: '/etc/named-iiab.conf', mode: '0644' }
|
||||||
- { src: 'named/school.local.zone.db', dest: '/var/named-iiab/', mode: '0644' }
|
- { src: 'named/school.local.zone.db', dest: '/var/named-iiab/', mode: '0644' }
|
||||||
- { src: 'named/school.internal.zone.db', dest: '/var/named-iiab/', mode: '0644' }
|
- { src: 'named/school.internal.zone.db', dest: '/var/named-iiab/', mode: '0644' }
|
||||||
when: named_enabled and named_install
|
when: named_install and named_enabled
|
||||||
|
|
||||||
- name: Enable named service ({{ dns_service }}) if named_enabled
|
- name: Enable named service ({{ dns_service }}) if named_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: "{{ dns_service }}"
|
name: "{{ dns_service }}"
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: named_enabled and named_install
|
when: named_install and named_enabled
|
||||||
|
|
||||||
- name: Disable named service ({{ dns_service }}) if not named_enabled
|
- name: Disable named service ({{ dns_service }}) if not named_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: "{{ dns_service }}"
|
name: "{{ dns_service }}"
|
||||||
enabled: no
|
enabled: no
|
||||||
when: not named_enabled and named_install
|
when: named_install and not named_enabled
|
||||||
|
|
||||||
- name: Install /etc/dnsmasq.d/iiab.conf from template, when dnsmasq_enabled and isn't Appliance
|
- name: Install /etc/dnsmasq.d/iiab.conf from template, when dnsmasq_enabled and isn't Appliance
|
||||||
template:
|
template:
|
||||||
src: network/dnsmasq.conf.j2
|
src: network/dnsmasq.conf.j2
|
||||||
dest: /etc/dnsmasq.d/iiab.conf
|
dest: /etc/dnsmasq.d/iiab.conf
|
||||||
when: dnsmasq_enabled and dnsmasq_install and (iiab_network_mode != "Appliance")
|
when: dnsmasq_install and dnsmasq_enabled and (iiab_network_mode != "Appliance")
|
||||||
|
|
||||||
- name: Copy script to restart dnsmasq whenever br0 comes up
|
## Another way to skin the cat
|
||||||
template:
|
##- name: Check if systemd service networkd-dispatcher is enabled
|
||||||
src: "roles/network/templates/network/dnsmasq.sh.j2"
|
## systemd:
|
||||||
dest: "/etc/networkd-dispatcher/routable.d/dnsmasq.sh"
|
## name: networkd-dispatcher
|
||||||
mode: "0755"
|
## state: reloaded
|
||||||
|
## register: systemd_out
|
||||||
|
##
|
||||||
|
## Yet Another
|
||||||
|
## command: systemctl show networkd-dispatcher | grep ^UnitFileState=
|
||||||
|
## would yield "UnitFileState=enabled"
|
||||||
|
##
|
||||||
|
#- name: Check if systemd service networkd-dispatcher is enabled
|
||||||
|
# command: systemctl is-enabled networkd-dispatcher
|
||||||
|
# register: nd_enabled
|
||||||
|
# ignore_errors: True
|
||||||
|
#
|
||||||
|
#- debug:
|
||||||
|
# var: nd_enabled
|
||||||
|
|
||||||
|
- name: Check if /etc/networkd-dispatcher/routable.d exists
|
||||||
|
stat:
|
||||||
|
path: /etc/networkd-dispatcher/routable.d
|
||||||
|
register: nd_dir
|
||||||
|
|
||||||
|
#- debug:
|
||||||
|
# var: nd_dir
|
||||||
|
|
||||||
|
#- name: To restart dnsmasq whenever br0 comes up, install /etc/networkd-dispatcher/routable.d/dnsmasq.sh from template (if isn't Appliance, and networkd-dispatcher is enabled, and directory /etc/networkd-dispatcher/routable.d exists, i.e. OS's like Ubuntu 18.04)
|
||||||
|
- name: To restart dnsmasq whenever br0 comes up, install /etc/networkd-dispatcher/routable.d/dnsmasq.sh from template (if isn't Appliance, and directory /etc/networkd-dispatcher/routable.d exists, i.e. OS's like Ubuntu 18.04)
|
||||||
|
template:
|
||||||
|
src: roles/network/templates/network/dnsmasq.sh.j2
|
||||||
|
dest: /etc/networkd-dispatcher/routable.d/dnsmasq.sh
|
||||||
|
mode: 0755
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
when: dnsmasq_enabled and dnsmasq_install and (iiab_network_mode != "Appliance") and (not is_rpi)
|
when: dnsmasq_install and dnsmasq_enabled and nd_dir.stat.exists and nd_dir.stat.isdir and (iiab_network_mode != "Appliance")
|
||||||
|
#when: dnsmasq_install and dnsmasq_enabled and nd_enabled is defined and nd_enabled.stdout == "enabled" and nd_dir.stat.exists and nd_dir.stat.isdir and (iiab_network_mode != "Appliance")
|
||||||
|
#when: dnsmasq_install and dnsmasq_enabled and systemd_out.status.UnitFileState == "enabled" and networkd_dir.stat.exists and networkd_dir.stat.isdir and (iiab_network_mode != "Appliance")
|
||||||
|
#when: dnsmasq_enabled and dnsmasq_install and (iiab_network_mode != "Appliance") and (not is_rpi) and (not is_ubuntu_16)
|
||||||
|
|
||||||
- name: Remove /etc/dnsmasq.d/iiab.conf, when not dnsmasq_enabled or is Appliance
|
- name: Remove /etc/dnsmasq.d/iiab.conf, when not dnsmasq_enabled or is Appliance
|
||||||
file:
|
file:
|
||||||
|
@ -73,25 +104,25 @@
|
||||||
systemd:
|
systemd:
|
||||||
name: iiab-dnsmasq
|
name: iiab-dnsmasq
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: dnsmasq_enabled and dnsmasq_install
|
when: dnsmasq_install and dnsmasq_enabled
|
||||||
|
|
||||||
- name: Disable iiab-dnsmasq, if not dnsmasq_enabled
|
- name: Disable iiab-dnsmasq, if not dnsmasq_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: iiab-dnsmasq
|
name: iiab-dnsmasq
|
||||||
enabled: no
|
enabled: no
|
||||||
when: not dnsmasq_enabled and dnsmasq_install
|
when: dnsmasq_install and not dnsmasq_enabled
|
||||||
|
|
||||||
- name: Enable DansGuardian systemd service, if dansguardian_enabled
|
- name: Enable DansGuardian systemd service, if dansguardian_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: dansguardian
|
name: dansguardian
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: dansguardian_enabled and dansguardian_install
|
when: dansguardian_install and dansguardian_enabled
|
||||||
|
|
||||||
- name: Disable DansGuardian, if not dansguardian_enabled
|
- name: Disable DansGuardian, if not dansguardian_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: dansguardian
|
name: dansguardian
|
||||||
enabled: no
|
enabled: no
|
||||||
when: not dansguardian_enabled and dansguardian_install
|
when: dansguardian_install and not dansguardian_enabled
|
||||||
|
|
||||||
- name: Mandate 'HTTPCACHE_ON=True' in {{ iiab_env_file }}, if squid_enabled
|
- name: Mandate 'HTTPCACHE_ON=True' in {{ iiab_env_file }}, if squid_enabled
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -99,13 +130,13 @@
|
||||||
regexp: '^HTTPCACHE_ON=*'
|
regexp: '^HTTPCACHE_ON=*'
|
||||||
line: 'HTTPCACHE_ON=True'
|
line: 'HTTPCACHE_ON=True'
|
||||||
state: present
|
state: present
|
||||||
when: squid_enabled and squid_install
|
when: squid_install and squid_enabled
|
||||||
|
|
||||||
- name: Enable Squid systemd service ({{ proxy }}) if squid_enabled
|
- name: Enable Squid systemd service ({{ proxy }}) if squid_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: "{{ proxy }}"
|
name: "{{ proxy }}"
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: squid_enabled and squid_install
|
when: squid_install and squid_enabled
|
||||||
|
|
||||||
- name: Install /etc/{{ proxy }}/squid-iiab.conf from template, owned by {{ proxy_user }}:{{ proxy_user }}
|
- name: Install /etc/{{ proxy }}/squid-iiab.conf from template, owned by {{ proxy_user }}:{{ proxy_user }}
|
||||||
template:
|
template:
|
||||||
|
@ -120,20 +151,20 @@
|
||||||
owner: "{{ proxy_user }}"
|
owner: "{{ proxy_user }}"
|
||||||
group: "{{ proxy_user }}"
|
group: "{{ proxy_user }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: squid_enabled and squid_install
|
when: squid_install and squid_enabled
|
||||||
|
|
||||||
- name: Point to Squid config file from startup file, if squid_enabled (debuntu)
|
- name: Point to Squid config file from startup file, if squid_enabled (debuntu)
|
||||||
lineinfile:
|
lineinfile:
|
||||||
regexp: '^CONFIG'
|
regexp: '^CONFIG'
|
||||||
line: "CONFIG=/etc/{{ proxy }}/squid-iiab.conf"
|
line: "CONFIG=/etc/{{ proxy }}/squid-iiab.conf"
|
||||||
path: "/etc/init.d/{{ proxy }}"
|
path: "/etc/init.d/{{ proxy }}"
|
||||||
when: squid_enabled and squid_install and is_debuntu
|
when: squid_install and squid_enabled and is_debuntu
|
||||||
|
|
||||||
- name: Disable Squid service, if not squid_enabled
|
- name: Disable Squid service, if not squid_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: "{{ proxy }}"
|
name: "{{ proxy }}"
|
||||||
enabled: no
|
enabled: no
|
||||||
when: not squid_enabled and squid_install
|
when: squid_install and not squid_enabled
|
||||||
|
|
||||||
- name: Revert to 'HTTPCACHE_ON=False' if not squid_enabled
|
- name: Revert to 'HTTPCACHE_ON=False' if not squid_enabled
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -141,19 +172,19 @@
|
||||||
regexp: '^HTTPCACHE_ON=*'
|
regexp: '^HTTPCACHE_ON=*'
|
||||||
line: 'HTTPCACHE_ON=False'
|
line: 'HTTPCACHE_ON=False'
|
||||||
state: present
|
state: present
|
||||||
when: not squid_enabled
|
when: squid_install and not squid_enabled
|
||||||
|
|
||||||
- name: Enable Wondershaper service, if wondershaper_enabled
|
- name: Enable Wondershaper service, if wondershaper_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: wondershaper
|
name: wondershaper
|
||||||
enabled: yes
|
enabled: yes
|
||||||
when: wondershaper_enabled and wondershaper_install
|
when: wondershaper_install and wondershaper_enabled
|
||||||
|
|
||||||
- name: Disable Wondershaper service, if not wondershaper_enabled
|
- name: Disable Wondershaper service, if not wondershaper_enabled
|
||||||
systemd:
|
systemd:
|
||||||
name: wondershaper
|
name: wondershaper
|
||||||
enabled: no
|
enabled: no
|
||||||
when: not wondershaper_enabled and wondershaper_install
|
when: wondershaper_install and not wondershaper_enabled
|
||||||
|
|
||||||
# check-LAN should be iptables.yml remove later
|
# check-LAN should be iptables.yml remove later
|
||||||
- name: Install clean copy of /usr/bin/iiab-gen-iptables from template
|
- name: Install clean copy of /usr/bin/iiab-gen-iptables from template
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$IFACE" == "{{ iiab_lan_iface }}" ];
|
if [ "$IFACE" == "{{ iiab_lan_iface }}" ]; then
|
||||||
then
|
/bin/systemctl restart dnsmasq.service
|
||||||
/bin/systemctl restart dnsmasq.service
|
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue