1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Merge pull request #1694 from holta/network-ansible-cleanup

Clean roles/0-init & roles/network for Ansible 2.8 ('| bool'). Prep for Ubuntu 18/19+
This commit is contained in:
A Holt 2019-05-24 13:23:38 -04:00 committed by GitHub
commit 3b4200b316
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 55 additions and 52 deletions

View file

@ -8,7 +8,7 @@ first_run: False
rpi_model: none rpi_model: none
is_rpi: False is_rpi: False
xo_model: none xo_model: none
gw_active: none gw_active: False
internet_available: False internet_available: False
discovered_wan_iface: none discovered_wan_iface: none

View file

@ -13,7 +13,7 @@
- name: 'Turn the crank for systemd: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" (debuntu)' - name: 'Turn the crank for systemd: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" (debuntu)'
shell: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" shell: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}"
when: is_debuntu when: is_debuntu | bool
- name: Install /etc/sysconfig/network from template (redhat) - name: Install /etc/sysconfig/network from template (redhat)
template: template:
@ -22,7 +22,7 @@
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
when: is_redhat when: is_redhat | bool
- name: Put hostnames "127.0.0.1 localhost.localdomain localhost box {{ iiab_hostname }}" in /etc/hosts - name: Put hostnames "127.0.0.1 localhost.localdomain localhost box {{ iiab_hostname }}" in /etc/hosts
lineinfile: lineinfile:

View file

@ -14,7 +14,7 @@
# sections once and only once to preserve the install date and git hash. # sections once and only once to preserve the install date and git hash.
- name: Create IIAB directory structure and {{ iiab_ini_file }}, if first_run - name: Create IIAB directory structure and {{ iiab_ini_file }}, if first_run
include_tasks: first_run.yml include_tasks: first_run.yml
when: first_run when: first_run | bool
#- name: Loading computed_vars #- name: Loading computed_vars
# include_tasks: roles/0-init/tasks/computed_vars.yml # include_tasks: roles/0-init/tasks/computed_vars.yml
@ -92,7 +92,7 @@
- name: Set port 443 for Admin Console if adm_cons_force_ssl - name: Set port 443 for Admin Console if adm_cons_force_ssl
set_fact: set_fact:
gui_port: 443 gui_port: 443
when: adm_cons_force_ssl when: adm_cons_force_ssl | bool
- name: Turn on both vars for MySQL (mandatory in Stage 3!) - name: Turn on both vars for MySQL (mandatory in Stage 3!)
set_fact: set_fact:
@ -127,12 +127,12 @@
- name: "Set python_path: /lib/python2.7/site-packages/ (redhat)" - name: "Set python_path: /lib/python2.7/site-packages/ (redhat)"
set_fact: set_fact:
python_path: /lib/python2.7/site-packages/ python_path: /lib/python2.7/site-packages/
when: is_redhat when: is_redhat | bool
- name: "Set python_path: /usr/local/lib/python2.7/dist-packages/ (debuntu)" - name: "Set python_path: /usr/local/lib/python2.7/dist-packages/ (debuntu)"
set_fact: set_fact:
python_path: /usr/local/lib/python2.7/dist-packages/ python_path: /usr/local/lib/python2.7/dist-packages/
when: is_debuntu when: is_debuntu | bool
# For various reasons the mysql service cannot be enabled on Fedora 20, but # For various reasons the mysql service cannot be enabled on Fedora 20, but
# 'mariadb', which is its real name can. On Fedora 18 we need to use 'mysqld'. # 'mariadb', which is its real name can. On Fedora 18 we need to use 'mysqld'.
@ -154,7 +154,7 @@
#- name: "Set mysql_service: mysql (debuntu)" #- name: "Set mysql_service: mysql (debuntu)"
# set_fact: # set_fact:
# mysql_service: mysql # mysql_service: mysql
# when: is_debuntu # when: is_debuntu | bool
- name: "Set iiab_fqdn: {{ iiab_hostname }}.{{ iiab_domain }}" - name: "Set iiab_fqdn: {{ iiab_hostname }}.{{ iiab_domain }}"
set_fact: set_fact:
@ -168,7 +168,7 @@
- name: Set hostname if FQDN_changed - name: Set hostname if FQDN_changed
include_tasks: hostname.yml include_tasks: hostname.yml
when: FQDN_changed when: FQDN_changed | bool
- name: Add 'runtime' variable values to {{ iiab_ini_file }} - name: Add 'runtime' variable values to {{ iiab_ini_file }}
ini_file: ini_file:
@ -202,21 +202,21 @@
- option: product_id - option: product_id
value: "{{ ansible_product_uuid }}" value: "{{ ansible_product_uuid }}"
- option: gw_active - option: gw_active
value: "{{ gw_active }}" value: "{{ gw_active }}"
- option: internet_available - option: internet_available
value: "{{ internet_available }}" value: "{{ internet_available }}"
- option: is_rpi - option: is_rpi
value: "{{ is_rpi }}" value: "{{ is_rpi }}"
- option: first_run - option: first_run
value: "{{ first_run }}" value: "{{ first_run }}"
- option: local_tz - option: local_tz
value: "{{ local_tz }}" value: "{{ local_tz }}"
- option: no_NM_reload - option: no_NM_reload
value: "{{ no_NM_reload }}" value: "{{ no_NM_reload }}"
- option: is_F18 - option: is_F18
value: "{{ is_F18 }}" value: "{{ is_F18 }}"
- option: FQDN_changed - option: FQDN_changed
value: "{{ FQDN_changed }}" value: "{{ FQDN_changed }}"
- name: Add 'runtime' variable 'is_VM' value if defined, to {{ iiab_ini_file }} - name: Add 'runtime' variable 'is_VM' value if defined, to {{ iiab_ini_file }}
ini_file: ini_file:
@ -226,7 +226,7 @@
value: "{{ item.value }}" value: "{{ item.value }}"
with_items: with_items:
- option: is_VM - option: is_VM
value: "yes" value: "yes"
when: is_VM is defined when: is_VM is defined
- name: STAGE 0 HAS COMPLETED ====================================== - name: STAGE 0 HAS COMPLETED ======================================

View file

@ -3,7 +3,7 @@
name: avahi name: avahi
createhome: no createhome: no
shell: /bin/false shell: /bin/false
when: is_debuntu when: is_debuntu | bool
- name: Install avahi announce config file /etc/avahi/services/schoolserver.service - name: Install avahi announce config file /etc/avahi/services/schoolserver.service
template: template:
@ -37,7 +37,7 @@
copy: copy:
src: /usr/share/doc/avahi-daemon/examples/ssh.service src: /usr/share/doc/avahi-daemon/examples/ssh.service
dest: /etc/avahi/services/ dest: /etc/avahi/services/
when: is_debuntu when: is_debuntu | bool
- name: Set ssh port for avahi - name: Set ssh port for avahi
lineinfile: lineinfile:

View file

@ -60,7 +60,8 @@
- name: Checking iiab_wan_enabled - name: Checking iiab_wan_enabled
set_fact: set_fact:
user_wan_iface: "none" user_wan_iface: "none"
when: 'not iiab_wan_enabled' when: not iiab_wan_enabled
#when: 'not iiab_wan_enabled'
# gui wants LanController # keeps ifcfg-WAN but onboot=no # gui wants LanController # keeps ifcfg-WAN but onboot=no
# the change over might be a little bumpy ATM. # the change over might be a little bumpy ATM.
@ -141,7 +142,7 @@
set_fact: set_fact:
iiab_lan_iface: "br0" iiab_lan_iface: "br0"
iiab_wireless_lan_iface: "wlan0" iiab_wireless_lan_iface: "wlan0"
when: is_rpi when: is_rpi | bool
- name: Enable hostapd if discovered_wireless_iface is not WAN - name: Enable hostapd if discovered_wireless_iface is not WAN
set_fact: set_fact:

View file

@ -21,7 +21,7 @@
owner: dansguardian owner: dansguardian
group: dansguardian group: dansguardian
mode: 0640 mode: 0640
when: is_debuntu when: is_debuntu | bool
- name: Install /etc/dansguardian/dansguardian.conf from template (CentOS) - name: Install /etc/dansguardian/dansguardian.conf from template (CentOS)
template: template:

View file

@ -73,13 +73,13 @@
service: service:
name: dhcpd name: dhcpd
state: stopped state: stopped
when: dhcpd_install when: dhcpd_install | bool
- name: dhcpd_server may be affected - stopping dnsmasq - name: dhcpd_server may be affected - stopping dnsmasq
service: service:
name: dnsmasq name: dnsmasq
state: stopped state: stopped
when: dnsmasq_install when: dnsmasq_install | bool
- name: Reload systemd - name: Reload systemd
systemd: systemd:

View file

@ -17,7 +17,7 @@
- name: Red Hat network detection (redhat) - name: Red Hat network detection (redhat)
include_tasks: detected_redhat.yml include_tasks: detected_redhat.yml
when: is_redhat when: is_redhat | bool
- name: Setting dhcpcd_test results - name: Setting dhcpcd_test results
set_fact: set_fact:
@ -40,7 +40,7 @@
- name: Check /etc/network/interfaces for gateway - name: Check /etc/network/interfaces for gateway
shell: grep {{ device_gw }} /etc/network/interfaces | wc -l shell: grep {{ device_gw }} /etc/network/interfaces | wc -l
when: is_debuntu when: is_debuntu | bool
register: wan_file register: wan_file
- name: Setting wan_in_interfaces - name: Setting wan_in_interfaces

View file

@ -2,7 +2,7 @@
package: package:
name: isc-dhcp-server name: isc-dhcp-server
state: present state: present
when: is_debuntu when: is_debuntu | bool
tags: tags:
- download - download
@ -18,21 +18,22 @@
user: user:
name: dhcpd name: dhcpd
createhome: no createhome: no
when: is_debuntu when: is_debuntu | bool
- name: Disable stock dhcp_service (debuntu) - name: Disable stock dhcp_service (debuntu)
service: service:
name: "{{ dhcp_service }}" name: "{{ dhcp_service }}"
enabled: no enabled: no
state: stopped state: stopped
when: is_debuntu when: is_debuntu | bool
- name: Disable stock dhcp_service ipv6 (ubuntu-18) - name: Disable stock dhcp_service ipv6 (ubuntu-18 and higher)
service: service:
name: "{{ dhcp_service }}6" name: "{{ dhcp_service }}6"
enabled: no enabled: no
state: stopped state: stopped
when: is_ubuntu_18 when: is_ubuntu and not is_ubuntu_16
#when: is_ubuntu_18
- name: Install systemd unit file to /etc/systemd/system/dhcpd.service - name: Install systemd unit file to /etc/systemd/system/dhcpd.service
template: template:
@ -48,7 +49,7 @@
command: touch /var/lib/dhcpd/dhcpd.leases command: touch /var/lib/dhcpd/dhcpd.leases
args: args:
creates: /var/lib/dhcpd/dhcpd.leases creates: /var/lib/dhcpd/dhcpd.leases
when: is_redhat when: is_redhat | bool
- name: Set dhcpd.leases permissions/ownership (redhat) - name: Set dhcpd.leases permissions/ownership (redhat)
file: file:
@ -57,4 +58,4 @@
group: dhcpd group: dhcpd
mode: 0644 mode: 0644
state: file state: file
when: is_redhat when: is_redhat | bool

View file

@ -16,10 +16,10 @@
service: service:
name: dhcpd name: dhcpd
state: stopped state: stopped
when: dhcpd_install when: dhcpd_install | bool
- name: dhcpd_server may be affected - stopping dnsmasq - name: dhcpd_server may be affected - stopping dnsmasq
service: service:
name: dnsmasq name: dnsmasq
state: stopped state: stopped
when: dnsmasq_install when: dnsmasq_install | bool

View file

@ -31,7 +31,7 @@
owner: root owner: root
group: root group: root
mode: 0755 mode: 0755
when: is_rpi when: is_rpi | bool
- name: Create /usr/bin/iiab-hotspot-off from template - name: Create /usr/bin/iiab-hotspot-off from template
template: template:
@ -40,7 +40,7 @@
owner: root owner: root
group: root group: root
mode: 0755 mode: 0755
when: is_rpi when: is_rpi | bool
- name: Disable the Access Point 'hostapd' service - name: Disable the Access Point 'hostapd' service
systemd: systemd:

View file

@ -36,13 +36,13 @@
service: service:
name: dhcpd name: dhcpd
state: stopped state: stopped
when: dhcpd_install when: dhcpd_install | bool
- name: dhcpd_server may be affected - stopping dnsmasq - name: dhcpd_server may be affected - stopping dnsmasq
service: service:
name: dnsmasq name: dnsmasq
state: stopped state: stopped
when: dnsmasq_install when: dnsmasq_install | bool
- name: Stop the LAN/Bridge deleting iiab-LAN - name: Stop the LAN/Bridge deleting iiab-LAN
shell: nmcli con delete id iiab-LAN shell: nmcli con delete id iiab-LAN

View file

@ -57,7 +57,7 @@
- name: Configure wondershaper - name: Configure wondershaper
include_tasks: wondershaper.yml include_tasks: wondershaper.yml
when: wondershaper_install when: wondershaper_install | bool
tags: tags:
- network - network
- wondershaper - wondershaper
@ -99,7 +99,7 @@
#### Start network layout #### Start network layout
- name: Redhat networking - name: Redhat networking
include_tasks: ifcfg_mods.yml include_tasks: ifcfg_mods.yml
when: is_redhat when: is_redhat | bool
#and not installing #and not installing
tags: tags:
- network - network

View file

@ -4,7 +4,7 @@
- bind9 - bind9
- bind9utils - bind9utils
state: present state: present
when: is_debuntu when: is_debuntu | bool
tags: tags:
- download - download
@ -79,7 +79,7 @@
template: template:
src: roles/network/templates/named/dns-jail.conf src: roles/network/templates/named/dns-jail.conf
dest: "/etc/{{ apache_config_dir }}/" dest: "/etc/{{ apache_config_dir }}/"
when: dns_jail_enabled when: dns_jail_enabled | bool
- name: Create symlink dns-jail.conf from sites-enabled to sites-available (if debuntu and dns_jail_enabled) - name: Create symlink dns-jail.conf from sites-enabled to sites-available (if debuntu and dns_jail_enabled)
file: file:

View file

@ -27,7 +27,7 @@
enabled: yes enabled: yes
with_items: with_items:
- systemd-networkd-wait-online - systemd-networkd-wait-online
when: systemd_networkd_active when: systemd_networkd_active | bool
# ICO will always set gui_static_wan_ip away from the default of 'unset' while # ICO will always set gui_static_wan_ip away from the default of 'unset' while
# gui_static_wan turns dhcp on/off through wan_ip in computed_network and # gui_static_wan turns dhcp on/off through wan_ip in computed_network and

View file

@ -57,7 +57,7 @@
shell: nmcli conn up id iiab-WAN shell: nmcli conn up id iiab-WAN
register: dhcp_WAN register: dhcp_WAN
ignore_errors: yes ignore_errors: yes
when: has_WAN when: has_WAN | bool
- name: BAD ifcfg-WAN - name: BAD ifcfg-WAN
debug: debug:
@ -117,7 +117,7 @@
register: ifcfg_dhcp_device register: ifcfg_dhcp_device
ignore_errors: True ignore_errors: True
changed_when: False changed_when: False
when: dhcp_good when: dhcp_good | bool
- name: Setting has ifcfg gw based on device if found - name: Setting has ifcfg gw based on device if found
set_fact: set_fact:

View file

@ -15,13 +15,13 @@
name: "{{ proxy }}" name: "{{ proxy }}"
state: stopped state: stopped
async: 120 async: 120
when: squid_install when: squid_install | bool
- name: Stop DansGuardian - name: Stop DansGuardian
systemd: systemd:
name: dansguardian name: dansguardian
state: stopped state: stopped
when: dansguardian_install when: dansguardian_install | bool
- name: Restart DansGuardian service (dansguardian) except Ubuntu which needs reboot to activate - name: Restart DansGuardian service (dansguardian) except Ubuntu which needs reboot to activate
systemd: systemd:
@ -40,7 +40,7 @@
systemd: systemd:
name: wondershaper name: wondershaper
state: restarted state: restarted
when: wondershaper_enabled when: wondershaper_enabled | bool
- name: Restart Avahi service (avahi-daemon) - name: Restart Avahi service (avahi-daemon)
systemd: systemd:

View file

@ -9,7 +9,7 @@
- name: "Bigger hammer for Ubuntu, run: /etc/init.d/squid stop" - name: "Bigger hammer for Ubuntu, run: /etc/init.d/squid stop"
command: /etc/init.d/squid stop command: /etc/init.d/squid stop
when: is_ubuntu when: is_ubuntu | bool
- name: Stop Squid - name: Stop Squid
service: service:
@ -79,7 +79,7 @@
state: directory state: directory
- include_tasks: roles/network/tasks/dansguardian.yml - include_tasks: roles/network/tasks/dansguardian.yml
when: dansguardian_install when: dansguardian_install | bool
# {{ proxy }} is normally "squid", but is "squid3" on raspbian-8 & debian-8 # {{ proxy }} is normally "squid", but is "squid3" on raspbian-8 & debian-8
- name: Add '{{ proxy }}' variable values to {{ iiab_ini_file }} - name: Add '{{ proxy }}' variable values to {{ iiab_ini_file }}

View file

@ -33,11 +33,12 @@
wan_cidr: "{{ CIDR.stdout }}" wan_cidr: "{{ CIDR.stdout }}"
when: wan_ip != "dhcp" when: wan_ip != "dhcp"
- name: Supply static WAN template - name: Supply static WAN template (ubuntu-16)
template: template:
dest: /etc/systemd/network/IIAB-Static.network dest: /etc/systemd/network/IIAB-Static.network
src: network/systemd-static-net.j2 src: network/systemd-static-net.j2
when: wan_ip != "dhcp" and not is_ubuntu_18 when: wan_ip != "dhcp" and is_ubuntu_16
#when: wan_ip != "dhcp" and not is_ubuntu_18
- name: Stopping services - name: Stopping services
include_tasks: down-debian.yml include_tasks: down-debian.yml