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

softcode exclude devices, move tests and turn into hard failures, record wifi after channel detection, prior_gateway_device, fix ap0 exclude

This commit is contained in:
Jerry Vonau 2020-04-06 05:19:16 -05:00
parent 6783038b29
commit 1d4e427fa9
5 changed files with 46 additions and 62 deletions

View file

@ -62,13 +62,14 @@ strict_networking: False
iiab_demo_mode: False
gui_static_wan: False
wan_cidr:
virtual_network_devices: "-e ap0 -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth"
# Set defaults for discovery process as strings
wifi1: "not found-1"
wifi2: "not found-2"
exclude_device: "none"
device_gw: "none"
device_gw2: ""
prior_gw_device: ""
iiab_wan_iface: "none"
iiab_lan_iface: "none"

View file

@ -6,20 +6,6 @@
user_wan_iface: "{{ discovered_wan_iface }}"
when: not (discovered_wan_iface == "none") and not (xo_model == "none") and has_ifcfg_gw == "none"
#- name: Checking for NetworkManager-config-server
# shell: rpm -qa | grep NetworkManager-config-server | wc -l
# register: strict_networking_check
#- name: Found Checking for NetworkManager-config-server
# set_fact:
# strict_networking: True
# when: strict_networking_check == "1"
#- name: Use restricted network features
# set_fact:
# iiab_demo_mode: True
# when: teamviewer_install and not strict_networking
- name: XO laptop wants USB WiFi interface as AP mode
set_fact:
iiab_wireless_lan_iface: "{{ discovered_lan_iface }}"
@ -62,7 +48,7 @@
user_wan_iface: "none"
when: not iiab_wan_enabled
# gui wants LanController # keeps ifcfg-WAN but onboot=no
# gui wants LanController
# the change over might be a little bumpy ATM.
- name: Setting GUI wants 'LanController'
set_fact:
@ -71,10 +57,9 @@
iiab_gateway_enabled: "False"
when: gui_desired_network_role is defined and gui_desired_network_role == "LanController"
# device_gw is used with the LAN detection and LAN's ifcfg file deletion.
# single interface vars/ users would need to set iiab_wan_enabled False as above, to disable the WAN
# and set user_lan_iface = <device> to suppress the auto detection for the same effect.
# discovered_wan_iface is used with the LAN detection, single interface vars/ users would
# need to set iiab_wan_enabled False as above, to disable the WAN and set
# user_lan_iface: <device> to suppress the auto detection for the same effect.
- name: Setting user_lan_iface for 'LanController' for single interface
set_fact:
user_lan_iface: "{{ discovered_wan_iface }}"
@ -143,24 +128,6 @@
iiab_lan_iface: "{{ user_lan_iface }}"
when: not (user_lan_iface == "auto")
# so this works
- name: Interface count
shell: ls /sys/class/net | grep -v -e lo -e bridge0 -e veth -e "br-*" -e docker| wc | awk '{print $1}'
register: adapter_count
# well if there ever was a point to tell the user things are FUBAR this is it.
- name: We're hosed no work interfaces
set_fact:
iiab_network_mode: "No_network_found"
when: adapter_count.stdout|int == 0
# well if there ever was a point to tell the user things are FUBAR this is it.
- name: I'm not guessing declare gateway please
set_fact:
iiab_network_mode: "Undetectable_use_local_vars"
iiab_wan_iface: "none"
when: adapter_count.stdout|int >= 5 and device_gw == "none" and gui_wan_iface == "unset" and gui_static_wan is defined
- name: Record IIAB_WAN_DEVICE to {{ iiab_env_file }}
lineinfile:
path: "{{ iiab_env_file }}"
@ -197,11 +164,3 @@
value: "{{ iiab_lan_iface }}"
- option: iiab_network_mode
value: "{{ iiab_network_mode }}"
- option: hostapd_enabled
value: "{{ hostapd_enabled }}"
- option: host_ssid
value: "{{ host_ssid }}"
- option: host_wifi_mode
value: "{{ host_wifi_mode }}"
- option: host_channel
value: "{{ host_channel }}"

View file

@ -74,3 +74,11 @@
value: "{{ dnsmasq_enabled }}"
- option: no_net_restart
value: "{{ no_net_restart }}"
- option: hostapd_enabled
value: "{{ hostapd_enabled }}"
- option: host_ssid
value: "{{ host_ssid }}"
- option: host_wifi_mode
value: "{{ host_wifi_mode }}"
- option: host_channel
value: "{{ host_channel }}"

View file

@ -1,15 +1,26 @@
- name: iiab_wan_device
shell: grep IIAB_WAN_DEVICE {{ iiab_env_file }} | awk -F "=" '{print $2}'
when: iiab_stage|int > 4
register: prior_gw
# so this works
- name: Interface count
shell: ls /sys/class/net | grep -v {{ virtual_network_devices }} | wc | awk '{print $1}'
register: adapter_count
# well if there ever was a point to tell the user things are FUBAR this is it.
- name: We're hosed no work interfaces
fail: # FORCE IT RED THIS ONCE!
msg: "No_network_found"
when: adapter_count.stdout|int == 0
- name: Checking for old device gateway interface for device test
shell: grep IIAB_WAN_DEVICE {{ iiab_env_file }} | awk -F "=" '{print $2}'
when: iiab_stage|int == 9
register: prior_gw
- name: Setting device_gw, prior_gw_device
set_fact:
device_gw: "{{ prior_gw.stdout }}"
device_gw2: "{{ prior_gw.stdout }}"
when: iiab_stage|int > 4 and prior_gw is defined and prior_gw.stdout != ""
prior_gw_device: "{{ prior_gw.stdout }}"
when: prior_gw.stdout is defined and prior_gw.stdout != ""
- name: Setting WAN if detected
- name: Setting WAN, device_gw if detected
set_fact:
iiab_wan_iface: "{{ discovered_wan_iface }}"
device_gw: "{{ discovered_wan_iface }}"
@ -77,7 +88,7 @@
set_fact:
wifi2: "{{ item|trim }}"
discovered_wireless_iface: "{{ item|trim }}"
when: wireless_list2.stdout is defined and not wireless_list2.stdout == "ap0"
when: wireless_list2.stdout is defined and item|trim != "ap0"
with_items:
- "{{ wireless_list2.stdout_lines }}"
#item|trim != discovered_wan_iface
@ -86,7 +97,6 @@
shell: "ls -la /sys/class/net/*/phy80211 | awk -F / '{print $5}' | grep -v -e ap0 | wc -l"
register: count_wifi_interfaces
# facts are apparently all stored as text, so do text comparisons from here on
- name: Remember number of WiFi devices
set_fact:
num_wifi_interfaces: "{{ count_wifi_interfaces.stdout|int }}"
@ -96,17 +106,16 @@
- name: XO laptop override 2 WiFi on LAN
set_fact:
ap_device: "eth0"
exclude_device: "eth0"
when: iiab_wan_iface != "eth0" and discovered_wireless_iface != "none" and xo_model == "XO-1.5"
- name: Exclude reserved Network Adapter if defined - takes adapter name
set_fact:
exclude_device: "{{ reserved_device }}"
# when: reserved_device is defined and discovered_wireless_iface != iiab_wan_iface and num_wifi_interfaces >= "2"
when: reserved_device is defined
- name: Count LAN ifaces
shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ exclude_device }} | wc -l
shell: ls /sys/class/net | grep -v {{ virtual_network_devices }} -e wwlan -e ppp -e {{ device_gw }} -e {{ exclude_device }} | wc -l
register: num_lan_interfaces_result
- name: Calculate number of LAN interfaces including WiFi
@ -115,7 +124,7 @@
# LAN - pick non WAN's
- name: Create list of LAN (non WAN) ifaces
shell: ls /sys/class/net | grep -v -e ap0 -e wwlan -e ppp -e lo -e br0 -e tun -e br- -e docker -e bridge0 -e veth -e {{ device_gw }} -e {{ exclude_device }}
shell: ls /sys/class/net | grep -v {{ virtual_network_devices }} -e wwlan -e ppp -e {{ device_gw }} -e {{ exclude_device }}
when: num_lan_interfaces != "0"
register: lan_list_result
@ -196,8 +205,8 @@
with_items:
- option: has_ifcfg_gw
value: "{{ has_ifcfg_gw }}"
- option: prior_gateway_(device_gw2)
value: "{{ device_gw2 }}"
- option: prior_gateway_device
value: "{{ prior_gw_device }}"
- option: dhcpcd_result
value: "{{ dhcpcd_result }}"
- option: network_manager_active
@ -226,3 +235,10 @@
value: "{{ iiab_lan_iface }}"
- option: iiab_wan_iface
value: "{{ iiab_wan_iface }}"
# well if there ever was a point to tell the user things are FUBAR this is it.
# limit 2 network adapters wifi wired
- name: I'm not guessing declare gateway please
fail: # FORCE IT RED THIS ONCE!
msg: "Undetectable gateway or prior gateway for use with static network addressing from admin-console use local_vars to declare user_wan_iface"
when: adapter_count.stdout|int >=3 and gui_wan_iface == "unset" and gui_static_wan

View file

@ -51,9 +51,9 @@
#### Start services
- include_tasks: avahi.yml
- include_tasks: hostapd.yml
- include_tasks: computed_services.yml
- include_tasks: enable_services.yml
- include_tasks: hostapd.yml
#### End services