1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00

move internet detection to be global - adjused iiab.env 2

This commit is contained in:
Jerry Vonau 2017-09-23 02:04:55 -04:00
parent c9332b53e1
commit ae5434bd3d
3 changed files with 36 additions and 43 deletions

View file

@ -14,6 +14,38 @@
exFAT_enabled: True
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
ini_file: dest='{{ iiab_config_file }}'
section=runtime
@ -36,6 +68,10 @@
value: '{{ ansible_swaptotal_mb }}'
- option: 'product_id'
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
- name: If the TZ is not set in env, set it to UTC

View file

@ -20,40 +20,6 @@
device_gw2: "{{ 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
set_fact:
iiab_wan_iface: "{{ discovered_wan_iface }}"
@ -197,10 +163,6 @@
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- option: 'gw_active'
value: '{{ gw_active }}'
- option: 'internet_available'
value: '{{ internet_available }}'
- option: 'has_ifcfg_gw'
value: '{{ has_ifcfg_gw }}'
- option: 'discovered_wan_iface'

View file

@ -73,11 +73,6 @@
- include: prep.yml
when: first_run
- include: computed_vars.yml
- include: detected_network.yml
when: not installing
# Put conditional actions for hardware platforms here
- include: raspberry_pi_2.yml
when: first_run and rpi_model != "none"