2017-05-27 18:09:50 +00:00
- name : Disable dhcpd service
2018-07-12 17:50:32 +00:00
service :
name : dhcpd
enabled : no
2019-10-16 16:06:02 +00:00
when : (dhcpd_install or dhcpd_installed is defined) and not dhcpd_enabled
2017-05-27 18:09:50 +00:00
# service is restarted with NM dispatcher.d script
- name : Enable dhcpd service
2018-07-12 17:50:32 +00:00
service :
name : dhcpd
enabled : yes
2019-06-29 22:29:58 +00:00
when : dhcpd_install and dhcpd_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Install /etc/sysconfig/dhcpd, /etc/dhcpd-iiab.conf from templates
2018-07-12 17:50:32 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
owner : root
group : root
mode : "{{ item.mode }}"
2017-05-27 18:09:50 +00:00
with_items :
2018-07-12 17:50:32 +00:00
- { src: 'dhcp/dhcpd-env.j2', dest: '/etc/sysconfig/dhcpd', mode : '0644' }
2017-10-31 09:10:46 +00:00
- { src: 'dhcp/dhcpd-iiab.conf.j2', dest: '/etc/dhcpd-iiab.conf', mode : '0644' }
2019-06-29 22:29:58 +00:00
when : dhcpd_install and dhcpd_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Install /etc/named-iiab.conf and two *.zone.db files into /var/named-iiab
2018-07-12 17:50:32 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
owner : root
group : root
mode : "{{ item.mode }}"
2017-05-27 18:09:50 +00:00
with_items :
2018-07-12 17:51:59 +00:00
- { 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.internal.zone.db', dest: '/var/named-iiab/', mode : '0644' }
2019-06-29 22:29:58 +00:00
when : named_install and named_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Enable named service ({{ dns_service }}) if named_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : "{{ dns_service }}"
enabled : yes
2019-06-29 22:29:58 +00:00
when : named_install and named_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Disable named service ({{ dns_service }}) if not named_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : "{{ dns_service }}"
enabled : no
2019-10-16 16:06:02 +00:00
when : (named_install or named_installed is defined) and not named_enabled
2017-05-27 18:09:50 +00:00
2019-01-17 20:03:12 +00:00
- name : Install /etc/dnsmasq.d/iiab.conf from template, when dnsmasq_enabled and isn't Appliance
2018-07-12 17:50:32 +00:00
template :
src : network/dnsmasq.conf.j2
2019-01-17 16:41:48 +00:00
dest : /etc/dnsmasq.d/iiab.conf
2019-06-29 22:29:58 +00:00
when : dnsmasq_install and dnsmasq_enabled and (iiab_network_mode != "Appliance")
2019-12-11 05:54:33 +00:00
- name : Install /etc/hosts.dnsmasq from template for /etc/dnsmasq.d/iiab.conf (instead of using /etc/hosts)
2019-12-02 06:41:12 +00:00
template :
src : network/hosts-dnsmasq.j2
dest : /etc/hosts.dnsmasq
when : dnsmasq_install and dnsmasq_enabled and (iiab_network_mode != "Appliance")
2019-06-29 22:29:58 +00:00
## Another way to skin the cat
##- name: Check if systemd service networkd-dispatcher is enabled
## systemd:
## name: networkd-dispatcher
## 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 :
2019-06-27 23:58:10 +00:00
src : roles/network/templates/network/dnsmasq.sh.j2
dest : /etc/networkd-dispatcher/routable.d/dnsmasq.sh
mode : 0755
2019-06-23 07:57:19 +00:00
owner : root
group : root
2019-06-29 22:29:58 +00:00
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)
2019-06-23 07:57:19 +00:00
2019-01-17 20:03:12 +00:00
- name : Remove /etc/dnsmasq.d/iiab.conf, when not dnsmasq_enabled or is Appliance
2019-01-17 16:41:48 +00:00
file :
path : /etc/dnsmasq.d/iiab.conf
state : absent
when : (not dnsmasq_enabled) or (iiab_network_mode == "Appliance")
2018-12-16 13:52:50 +00:00
- name : Enable iiab-dnsmasq systemd service, if dnsmasq_enabled
2018-10-31 07:58:55 +00:00
systemd :
2018-12-16 13:52:50 +00:00
name : iiab-dnsmasq
2018-07-12 17:50:32 +00:00
enabled : yes
2019-06-29 22:29:58 +00:00
when : dnsmasq_install and dnsmasq_enabled
2017-09-09 21:12:05 +00:00
2018-12-16 13:52:50 +00:00
- name : Disable iiab-dnsmasq, if not dnsmasq_enabled
systemd :
name : iiab-dnsmasq
enabled : no
2019-06-29 22:29:58 +00:00
when : dnsmasq_install and not dnsmasq_enabled
2018-12-16 13:52:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Enable DansGuardian systemd service, if dansguardian_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : dansguardian
enabled : yes
2019-06-29 22:29:58 +00:00
when : dansguardian_install and dansguardian_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Disable DansGuardian, if not dansguardian_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : dansguardian
enabled : no
2019-10-16 16:06:02 +00:00
when : (dansguardian_install or dansguardian_installed is defined) and not dansguardian_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Mandate 'HTTPCACHE_ON=True' in {{ iiab_env_file }}, if squid_enabled
2018-07-12 17:50:32 +00:00
lineinfile :
2018-10-31 07:58:55 +00:00
path : "{{ iiab_env_file }}"
2018-07-12 17:50:32 +00:00
regexp : '^HTTPCACHE_ON=*'
line : 'HTTPCACHE_ON=True'
state : present
2019-06-29 22:29:58 +00:00
when : squid_install and squid_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Enable Squid systemd service ({{ proxy }}) if squid_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : "{{ proxy }}"
enabled : yes
2019-06-29 22:29:58 +00:00
when : squid_install and squid_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Install /etc/{{ proxy }}/squid-iiab.conf from template, owned by {{ proxy_user }}:{{ proxy_user }}
2018-07-12 17:50:32 +00:00
template :
src : "{{ item.src }}"
dest : "{{ item.dest }}"
owner : "{{ item.owner }}"
group : "{{ item.group }}"
mode : "{{ item.mode }}"
2017-05-27 18:09:50 +00:00
with_items :
2018-07-12 17:50:32 +00:00
- src : squid/squid-iiab.conf.j2
2018-07-12 18:04:52 +00:00
dest : "/etc/{{ proxy }}/squid-iiab.conf"
owner : "{{ proxy_user }}"
group : "{{ proxy_user }}"
2018-07-12 17:50:32 +00:00
mode : 0644
2019-06-29 22:29:58 +00:00
when : squid_install and squid_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Point to Squid config file from startup file, if squid_enabled (debuntu)
2018-07-12 17:50:32 +00:00
lineinfile :
regexp : '^CONFIG'
2018-07-12 18:04:52 +00:00
line : "CONFIG=/etc/{{ proxy }}/squid-iiab.conf"
2018-10-31 07:58:55 +00:00
path : "/etc/init.d/{{ proxy }}"
2019-06-29 22:29:58 +00:00
when : squid_install and squid_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Disable Squid service, if not squid_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : "{{ proxy }}"
enabled : no
2019-10-16 16:06:02 +00:00
when : (squid_install or squid_installed is defined) and not squid_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Revert to 'HTTPCACHE_ON=False' if not squid_enabled
2018-07-12 17:50:32 +00:00
lineinfile :
2018-10-15 10:41:58 +00:00
dest : "{{ iiab_env_file }}"
2018-07-12 17:50:32 +00:00
regexp : '^HTTPCACHE_ON=*'
line : 'HTTPCACHE_ON=False'
state : present
2019-06-29 22:29:58 +00:00
when : squid_install and not squid_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Enable Wondershaper service, if wondershaper_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : wondershaper
enabled : yes
2019-06-29 22:29:58 +00:00
when : wondershaper_install and wondershaper_enabled
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Disable Wondershaper service, if not wondershaper_enabled
systemd :
2018-07-12 17:50:32 +00:00
name : wondershaper
enabled : no
2019-10-16 16:06:02 +00:00
when : (wondershaper_install or wondershaper_installed is defined) and not wondershaper_enabled
2017-05-27 18:09:50 +00:00
2017-10-19 06:33:02 +00:00
# check-LAN should be iptables.yml remove later
2018-10-31 07:58:55 +00:00
- name : Install clean copy of /usr/bin/iiab-gen-iptables from template
2018-07-12 17:50:32 +00:00
template :
2018-10-31 07:58:55 +00:00
src : gateway/iiab-gen-iptables
dest : /usr/bin/iiab-gen-iptables
2018-07-12 17:50:32 +00:00
owner : root
group : root
mode : 0755
2017-05-27 18:09:50 +00:00
2018-10-31 07:58:55 +00:00
- name : Add 'squid' variable values to {{ iiab_ini_file }}
2018-07-12 17:50:32 +00:00
ini_file :
2018-10-31 07:58:55 +00:00
path : "{{ iiab_ini_file }}"
2018-07-12 17:50:32 +00:00
section : squid
option : "{{ item.option }}"
2020-01-12 02:41:37 +00:00
value : "{{ item.value | string }}"
2017-05-27 18:09:50 +00:00
with_items :
- option : enabled
value : "{{ squid_enabled }}"
2018-10-31 07:58:55 +00:00
- name : Add 'dansguardian' variable values to {{ iiab_ini_file }}
2018-07-12 17:50:32 +00:00
ini_file :
2018-10-31 07:58:55 +00:00
path : "{{ iiab_ini_file }}"
2018-07-12 17:50:32 +00:00
section : dansguardian
option : "{{ item.option }}"
2020-01-12 02:41:37 +00:00
value : "{{ item.value | string }}"
2017-05-27 18:09:50 +00:00
with_items :
- option : enabled
value : "{{ dansguardian_enabled }}"
2018-10-31 07:58:55 +00:00
- name : Add 'wondershaper' variable values to {{ iiab_ini_file }}
2018-07-12 17:50:32 +00:00
ini_file :
2018-10-31 07:58:55 +00:00
path : "{{ iiab_ini_file }}"
2018-07-12 17:50:32 +00:00
section : wondershaper
option : "{{ item.option }}"
2020-01-12 02:41:37 +00:00
value : "{{ item.value | string }}"
2017-05-27 18:09:50 +00:00
with_items :
- option : enabled
value : "{{ wondershaper_enabled }}"