2017-05-27 18:09:50 +00:00
# just lie about active gateway present on XOs to suppress ifcfg-WAN
# auto-creation/moving with XOs using NM/system-connections/ via keyfile.
# ifcfg-rh acts on /etc/sys*/net*/ifcfg-* where we search for devices.
2017-10-27 17:19:59 +00:00
- name : Setting XO has WiFi gateway
2017-05-27 18:09:50 +00:00
set_fact :
2018-01-11 05:32:41 +00:00
user_wan_iface : "{{ discovered_wan_iface }}"
2019-07-29 17:06:39 +00:00
when : not (discovered_wan_iface == "none") and not (xo_model == "none") and has_ifcfg_gw == "none"
2017-05-27 18:09:50 +00:00
2017-11-16 12:01:58 +00:00
#- name: Checking for NetworkManager-config-server
# shell: rpm -qa | grep NetworkManager-config-server | wc -l
# register: strict_networking_check
2017-05-27 18:09:50 +00:00
2017-11-16 12:01:58 +00:00
#- name: Found Checking for NetworkManager-config-server
# set_fact:
# strict_networking: True
# when: strict_networking_check == "1"
2017-05-27 18:09:50 +00:00
2017-11-16 12:01:58 +00:00
#- name: Use restricted network features
# set_fact:
# iiab_demo_mode: True
# when: teamviewer_install and not strict_networking
2017-05-27 18:09:50 +00:00
2017-10-27 17:13:11 +00:00
- name : XO laptop wants USB WiFi interface as AP mode
2017-05-27 18:09:50 +00:00
set_fact :
2018-01-11 05:32:41 +00:00
iiab_wireless_lan_iface : "{{ discovered_lan_iface }}"
2019-07-29 17:06:39 +00:00
when : num_wifi_interfaces >= "2" and not (xo_model == "none") and not (discovered_wan_iface == "none") and discovered_wireless_iface == "eth0"
2017-05-27 18:09:50 +00:00
# static backout suppy new template file
- name : gui-static-wan
set_fact :
wan_ip : dhcp
gui_static_wan_ip : undefined
2019-07-29 17:06:39 +00:00
when : not (gui_static_wan_ip == "unset") and not gui_static_wan
2017-05-27 18:09:50 +00:00
2017-10-27 17:13:11 +00:00
- name : Undo gui-static-wan by requesting new template file
2017-05-27 18:09:50 +00:00
set_fact :
2018-01-11 05:32:41 +00:00
has_WAN : False
2019-07-29 17:06:39 +00:00
when : not (gui_static_wan_ip == "unset") and not gui_static_wan
2017-05-27 18:09:50 +00:00
# figure out more than one interfaces to detect.
- name : Using GUI_STATIC info
set_fact :
has_WAN : False
has_ifcfg_gw : "none"
wan_ip : "{{ gui_static_wan_ip }}"
wan_netmask : "{{ gui_static_wan_netmask }}"
wan_gateway : "{{ gui_static_wan_gateway }}"
wan_nameserver : "{{ gui_static_wan_nameserver }}"
2019-07-29 17:06:39 +00:00
when : gui_static_wan or not (user_wan_iface == "auto")
2017-05-27 18:09:50 +00:00
# we need to have an interface name for ifcfg-WAN to be able to change gateway
# the DEVICE from the gui. Thanks to George for proving my point about knowing
# what device to switch to.
#- name: Using GUI_WAN info
# set_fact:
# user_wan_iface: "{{ gui_wan_iface }}"
# when: gui_wan_iface != "unset" and gui_desired_network_role is defined and gui_desired_network_role != "LanController"
# should make the GUI buttons the last call
2017-06-09 23:25:56 +00:00
- name : Checking iiab_wan_enabled
2017-05-27 18:09:50 +00:00
set_fact :
user_wan_iface : "none"
2019-05-24 07:06:43 +00:00
when : not iiab_wan_enabled
2017-05-27 18:09:50 +00:00
# gui wants LanController # keeps ifcfg-WAN but onboot=no
# the change over might be a little bumpy ATM.
2017-10-27 17:19:59 +00:00
- name : Setting GUI wants 'LanController'
2017-05-27 18:09:50 +00:00
set_fact :
device_gw : "none"
user_wan_iface : "none"
2017-06-09 23:25:56 +00:00
iiab_gateway_enabled : "False"
2017-05-27 18:09:50 +00:00
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.
2017-06-09 23:25:56 +00:00
# single interface vars/ users would need to set iiab_wan_enabled False as above, to disable the WAN
2017-05-27 18:09:50 +00:00
# and set user_lan_iface = <device> to suppress the auto detection for the same effect.
2017-10-27 17:43:15 +00:00
- name : Setting user_lan_iface for 'LanController' for single interface
2017-05-27 18:09:50 +00:00
set_fact :
2018-01-11 05:32:41 +00:00
user_lan_iface : "{{ discovered_wan_iface }}"
2019-07-29 17:06:39 +00:00
when : not (discovered_wan_iface == "none") and num_lan_interfaces == "0" and gui_desired_network_role is defined and gui_desired_network_role == "LanController"
2017-05-27 18:09:50 +00:00
# override with user_wan_iface setting if no longer in auto
2017-10-27 17:13:11 +00:00
- name : Setting user WAN fact
2017-05-27 18:09:50 +00:00
set_fact :
2017-06-09 23:25:56 +00:00
iiab_wan_iface : "{{ user_wan_iface }}"
2019-07-29 17:06:39 +00:00
when : not (user_wan_iface == "auto")
2017-05-27 18:09:50 +00:00
# user disabled interface - overriding all other entries
2017-06-09 23:25:56 +00:00
- name : Checking iiab_lan_enabled
2017-05-27 18:09:50 +00:00
set_fact :
user_lan_iface : "none"
2019-07-29 17:06:39 +00:00
when : not iiab_lan_enabled
2017-05-27 18:09:50 +00:00
2017-06-09 23:25:56 +00:00
# gui wants Appliance Note: could of used iiab_lan_enabled false
2017-10-27 17:43:15 +00:00
- name : Setting GUI wants 'Appliance'
2017-05-27 18:09:50 +00:00
set_fact :
user_lan_iface : "none"
2017-06-09 23:25:56 +00:00
iiab_gateway_enabled : "False"
2017-05-27 18:09:50 +00:00
when : gui_desired_network_role is defined and gui_desired_network_role == "Appliance"
# gui wants Gateway
2017-10-27 17:43:15 +00:00
- name : Setting GUI wants and has active 'Gateway'
2017-05-27 18:09:50 +00:00
set_fact :
user_lan_iface : "auto"
2017-06-09 23:25:56 +00:00
user_wan_iface : "{{ iiab_wan_iface }}"
2019-07-29 17:06:39 +00:00
when : gui_desired_network_role is defined and gui_desired_network_role == "Gateway" and not (iiab_wan_iface == "none")
2017-05-27 18:09:50 +00:00
# make it so number 2 vars should use user_wan_iface but we can cover a single
# wired if dhcp fails the interface should revert to LAN, static address should
2018-01-11 05:32:41 +00:00
# stick around but testing gateway response is not performed.
2017-05-27 18:09:50 +00:00
- name : User wants single wired interface as static or dhcp gateway
set_fact :
2018-01-11 16:41:51 +00:00
user_wan_iface : "{{ discovered_wan_iface }}" # Jan 2018: Holt discovered_lan_iface was UNDEFINED on WiFi-installed
# RPi (when re-running ./iiab-network) so "discovered_wan_iface" is a
# workaround -- please see https://github.com/iiab/iiab/pull/649
# This workaround can and should evolve as IIAB 6.5 matures!
2017-05-27 18:09:50 +00:00
when : num_lan_interfaces == "1" and user_lan_iface == "auto" and user_wan_iface == "auto"
2018-05-31 16:20:35 +00:00
- name : Use old gateway device info if not detected and using static ip
set_fact :
iiab_wan_iface : "{{ device_gw }}"
2019-07-29 17:06:39 +00:00
when : not (wan_ip == "dhcp") and iiab_wan_iface == "none"
2018-05-31 16:20:35 +00:00
2017-10-27 17:19:59 +00:00
- name : No LAN configured - 'Appliance' mode
2017-05-27 18:09:50 +00:00
set_fact :
2017-06-09 23:25:56 +00:00
iiab_network_mode : "Appliance"
when : iiab_lan_iface == "none"
2017-05-27 18:09:50 +00:00
2017-10-27 17:19:59 +00:00
- name : LAN configured - 'LanController' mode
2017-05-27 18:09:50 +00:00
set_fact :
2017-06-09 23:25:56 +00:00
iiab_network_mode : "LanController"
2019-07-29 17:06:39 +00:00
when : not (iiab_lan_iface == "none") and iiab_wan_iface == "none"
2017-05-27 18:09:50 +00:00
2017-10-27 17:19:59 +00:00
- name : LAN configured - 'Gateway' mode
2017-05-27 18:09:50 +00:00
set_fact :
2017-06-09 23:25:56 +00:00
iiab_network_mode : "Gateway"
2020-03-04 23:00:01 +00:00
when : (not (iiab_lan_iface == "none") and not (iiab_wan_iface == "none"))
2017-05-27 18:09:50 +00:00
# override with user_lan_iface setting if no longer in auto
- name : Setting user LAN fact
set_fact :
2017-06-09 23:25:56 +00:00
iiab_lan_iface : "{{ user_lan_iface }}"
2019-07-29 17:06:39 +00:00
when : not (user_lan_iface == "auto")
2017-05-27 18:09:50 +00:00
# so this works
2017-10-27 17:13:11 +00:00
- name : Interface count
2019-06-23 02:39:27 +00:00
shell : ls /sys/class/net | grep -v -e lo -e bridge0 -e veth -e "br-*" -e docker| wc | awk '{print $1}'
2017-05-27 18:09:50 +00:00
register : adapter_count
2017-10-27 17:13:11 +00:00
# well if there ever was a point to tell the user things are FUBAR this is it.
2017-05-27 18:09:50 +00:00
- name : We're hosed no work interfaces
set_fact :
2017-06-09 23:25:56 +00:00
iiab_network_mode : "No_network_found"
2017-05-27 18:09:50 +00:00
when : adapter_count.stdout|int == "0"
2017-10-27 17:43:15 +00:00
# well if there ever was a point to tell the user things are FUBAR this is it.
2017-05-27 18:09:50 +00:00
- name : I'm not guessing declare gateway please
set_fact :
2017-06-09 23:25:56 +00:00
iiab_network_mode : "Undetectable_use_local_vars"
iiab_wan_iface : "none"
2017-05-27 18:09:50 +00:00
when : adapter_count.stdout|int >= "5" and device_gw == "none" and gui_wan_iface == "unset" and gui_static_wan is defined
2018-10-15 10:41:58 +00:00
- name : Record IIAB_WAN_DEVICE to {{ iiab_env_file }}
2018-03-29 20:39:20 +00:00
lineinfile :
2020-02-04 00:54:04 +00:00
path : "{{ iiab_env_file }}"
2018-03-29 20:39:20 +00:00
regexp : '^IIAB_WAN_DEVICE=*'
2020-03-05 05:21:28 +00:00
line : 'IIAB_WAN_DEVICE={{ iiab_wan_iface }}'
2018-03-29 20:39:20 +00:00
when : not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml
2018-10-15 10:41:58 +00:00
- name : Record IIAB_LAN_DEVICE to {{ iiab_env_file }}
2018-03-29 20:39:20 +00:00
lineinfile :
2020-02-04 00:54:04 +00:00
path : "{{ iiab_env_file }}"
2018-03-29 20:39:20 +00:00
regexp : '^IIAB_LAN_DEVICE=*'
2020-03-05 05:21:28 +00:00
line : 'IIAB_LAN_DEVICE={{ iiab_lan_iface }}'
2018-03-29 20:39:20 +00:00
state : present
when : not installing #REMOVE THIS LINE IF installing IS ALWAYS false AS SET IN roles/0-init/defaults/main.yml
2018-10-15 11:01:09 +00:00
- name : Add 'computed_network' variable values to {{ iiab_ini_file }}
2018-01-11 05:32:41 +00:00
ini_file :
2018-10-15 08:53:20 +00:00
dest : "{{ iiab_ini_file }}"
2018-01-11 05:32:41 +00:00
section : computed_network
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 :
2018-01-11 05:32:41 +00:00
- option : iiab_wan_enabled
value : "{{ iiab_wan_enabled }}"
- option : user_wan_iface
value : "{{ user_wan_iface }}"
- option : iiab_wan_iface
value : "{{ iiab_wan_iface }}"
- option : iiab_lan_enabled
value : "{{ iiab_lan_enabled }}"
- option : user_lan_iface
value : "{{ user_lan_iface }}"
- option : iiab_lan_iface
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 }}"