mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
move internet detection to be global - adjused iiab.env 2
This commit is contained in:
parent
c9332b53e1
commit
ae5434bd3d
3 changed files with 36 additions and 43 deletions
|
@ -14,6 +14,38 @@
|
||||||
exFAT_enabled: True
|
exFAT_enabled: True
|
||||||
when: xo_model != "none"
|
when: xo_model != "none"
|
||||||
|
|
||||||
|
# Discover do we have a gateway? -- if ansible detects gateway, becomes WAN candidate
|
||||||
|
- name: Finding gateway
|
||||||
|
set_fact:
|
||||||
|
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
|
||||||
|
when: 'ansible_default_ipv4.gateway is defined'
|
||||||
|
|
||||||
|
- name: Verify gateway present
|
||||||
|
shell: ping -c4 "{{ ansible_default_ipv4.gateway }}" &> /dev/null ; echo $?
|
||||||
|
when: discovered_wan_iface != "none"
|
||||||
|
register: gw_active_test
|
||||||
|
|
||||||
|
- name: Recording gateway response
|
||||||
|
set_fact:
|
||||||
|
gw_active: True
|
||||||
|
when: discovered_wan_iface != "none" and gw_active_test.stdout == "0"
|
||||||
|
|
||||||
|
- name: Test for internet access
|
||||||
|
get_url: url="{{ iiab_download_url }}/heart-beat.txt" dest=/tmp/heart-beat.txt
|
||||||
|
ignore_errors: True
|
||||||
|
# async: 10
|
||||||
|
# poll: 2
|
||||||
|
register: internet_access_test
|
||||||
|
|
||||||
|
- name: Set internet_available true if wget succeeded
|
||||||
|
set_fact:
|
||||||
|
internet_available: True
|
||||||
|
when: not internet_access_test|failed and not disregard_network
|
||||||
|
|
||||||
|
- name: Cleanup internet test file
|
||||||
|
file: path=/tmp/heart-beat.txt
|
||||||
|
state=absent
|
||||||
|
|
||||||
- name: add version section
|
- name: add version section
|
||||||
ini_file: dest='{{ iiab_config_file }}'
|
ini_file: dest='{{ iiab_config_file }}'
|
||||||
section=runtime
|
section=runtime
|
||||||
|
@ -36,6 +68,10 @@
|
||||||
value: '{{ ansible_swaptotal_mb }}'
|
value: '{{ ansible_swaptotal_mb }}'
|
||||||
- option: 'product_id'
|
- option: 'product_id'
|
||||||
value: '{{ ansible_product_uuid }}'
|
value: '{{ ansible_product_uuid }}'
|
||||||
|
- option: 'gw_active'
|
||||||
|
value: '{{ gw_active }}'
|
||||||
|
- option: 'internet_available'
|
||||||
|
value: '{{ internet_available }}'
|
||||||
|
|
||||||
# Put all computed vars here so derive properly from any prior var file
|
# Put all computed vars here so derive properly from any prior var file
|
||||||
- name: If the TZ is not set in env, set it to UTC
|
- name: If the TZ is not set in env, set it to UTC
|
||||||
|
|
|
@ -20,40 +20,6 @@
|
||||||
device_gw2: "{{ prior_gw.stdout }}"
|
device_gw2: "{{ prior_gw.stdout }}"
|
||||||
when: not first_run and prior_gw is defined and prior_gw.stdout != ""
|
when: not first_run and prior_gw is defined and prior_gw.stdout != ""
|
||||||
|
|
||||||
#pause checking
|
|
||||||
|
|
||||||
# Discover do we have a gateway? -- if ansible detects gateway, becomes WAN candidate
|
|
||||||
- name: Finding gateway
|
|
||||||
set_fact:
|
|
||||||
discovered_wan_iface: "{{ ansible_default_ipv4.alias }}"
|
|
||||||
when: 'ansible_default_ipv4.gateway is defined'
|
|
||||||
|
|
||||||
- name: Verify gateway present
|
|
||||||
shell: ping -c2 "{{ ansible_default_ipv4.gateway }}" &> /dev/null ; echo $?
|
|
||||||
register: gw_active_test
|
|
||||||
when: discovered_wan_iface != "none"
|
|
||||||
|
|
||||||
- name: Recording gateway response
|
|
||||||
set_fact:
|
|
||||||
gw_active: True
|
|
||||||
when: discovered_wan_iface != "none" and gw_active_test.stdout == "0"
|
|
||||||
|
|
||||||
- name: Test for internet access
|
|
||||||
get_url: url="{{ iiab_download_url }}/heart-beat.txt" dest=/tmp/heart-beat.txt
|
|
||||||
ignore_errors: True
|
|
||||||
# async: 10
|
|
||||||
# poll: 2
|
|
||||||
register: internet_access_test
|
|
||||||
|
|
||||||
- name: Set internet_available true if wget succeeded
|
|
||||||
set_fact:
|
|
||||||
internet_available: True
|
|
||||||
when: not internet_access_test|failed and not disregard_network
|
|
||||||
|
|
||||||
- name: Cleanup internet test file
|
|
||||||
file: path=/tmp/heart-beat.txt
|
|
||||||
state=absent
|
|
||||||
|
|
||||||
- name: Setting wan if detected
|
- name: Setting wan if detected
|
||||||
set_fact:
|
set_fact:
|
||||||
iiab_wan_iface: "{{ discovered_wan_iface }}"
|
iiab_wan_iface: "{{ discovered_wan_iface }}"
|
||||||
|
@ -197,10 +163,6 @@
|
||||||
option='{{ item.option }}'
|
option='{{ item.option }}'
|
||||||
value='{{ item.value }}'
|
value='{{ item.value }}'
|
||||||
with_items:
|
with_items:
|
||||||
- option: 'gw_active'
|
|
||||||
value: '{{ gw_active }}'
|
|
||||||
- option: 'internet_available'
|
|
||||||
value: '{{ internet_available }}'
|
|
||||||
- option: 'has_ifcfg_gw'
|
- option: 'has_ifcfg_gw'
|
||||||
value: '{{ has_ifcfg_gw }}'
|
value: '{{ has_ifcfg_gw }}'
|
||||||
- option: 'discovered_wan_iface'
|
- option: 'discovered_wan_iface'
|
||||||
|
|
|
@ -73,11 +73,6 @@
|
||||||
- include: prep.yml
|
- include: prep.yml
|
||||||
when: first_run
|
when: first_run
|
||||||
|
|
||||||
- include: computed_vars.yml
|
|
||||||
|
|
||||||
- include: detected_network.yml
|
|
||||||
when: not installing
|
|
||||||
|
|
||||||
# Put conditional actions for hardware platforms here
|
# Put conditional actions for hardware platforms here
|
||||||
- include: raspberry_pi_2.yml
|
- include: raspberry_pi_2.yml
|
||||||
when: first_run and rpi_model != "none"
|
when: first_run and rpi_model != "none"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue