2017-09-20 05:48:30 +00:00
|
|
|
- name: Checking for ifcfg-WAN file - Can Fail
|
2018-10-08 21:52:40 +00:00
|
|
|
stat:
|
|
|
|
path: /etc/sysconfig/network-scripts/ifcfg-WAN
|
2017-09-20 05:48:30 +00:00
|
|
|
when: not first_run
|
2017-09-26 17:23:25 +00:00
|
|
|
register: has_ifcfg_WAN
|
|
|
|
ignore_errors: True
|
2017-09-20 05:48:30 +00:00
|
|
|
|
|
|
|
- name: Setting ifcfg-WAN True
|
|
|
|
set_fact:
|
|
|
|
has_WAN: True
|
2017-09-26 17:23:25 +00:00
|
|
|
when: not first_run and has_ifcfg_WAN.stat.exists
|
2017-09-20 05:48:30 +00:00
|
|
|
|
2017-09-26 17:23:25 +00:00
|
|
|
# DETECT -- gateway and wireless - Can Fail
|
2017-09-20 05:48:30 +00:00
|
|
|
- name: Get a list of slaves from previous config - Can Fail
|
|
|
|
shell: "egrep -rn BRIDGE=br0 /etc/sysconfig/network-scripts/ifcfg-* | gawk -F'[-:]' '{print $3}'"
|
2017-09-26 17:23:25 +00:00
|
|
|
when: not first_run
|
2017-09-20 05:48:30 +00:00
|
|
|
register: ifcfg_slaves
|
|
|
|
ignore_errors: True
|
|
|
|
changed_when: False
|
|
|
|
|
|
|
|
# returns list of paths
|
2017-09-26 17:23:25 +00:00
|
|
|
- name: Find gateway config based on device - Can Fail
|
2017-09-20 05:48:30 +00:00
|
|
|
shell: "egrep -rn {{ device_gw }} /etc/sysconfig/network-scripts/ifcfg* | gawk -F ':' '{print $1}'"
|
2017-09-26 17:23:25 +00:00
|
|
|
when: not first_run and device_gw != "none"
|
2017-09-20 05:48:30 +00:00
|
|
|
register: ifcfg_gw_device
|
|
|
|
ignore_errors: True
|
|
|
|
changed_when: False
|
|
|
|
|
|
|
|
# last match wins
|
|
|
|
- name: Setting has ifcfg gw based on device if found
|
|
|
|
set_fact:
|
|
|
|
has_ifcfg_gw: "{{ item|trim }}"
|
|
|
|
when: ifcfg_gw_device.stdout_lines is defined and item|trim != "" and item|trim != "/etc/sysconfig/network-scripts/ifcfg-LAN"
|
|
|
|
with_items:
|
2018-10-08 21:51:15 +00:00
|
|
|
- "{{ ifcfg_gw_device.stdout_lines }}"
|
2017-09-26 17:23:25 +00:00
|
|
|
ignore_errors: True
|
2017-09-20 05:48:30 +00:00
|
|
|
|
|
|
|
# returns path
|
|
|
|
- name: Find active gateway config based on macaddress - Can Fail
|
|
|
|
shell: "egrep -irn {{ ansible_default_ipv4.macaddress }} /etc/sysconfig/network-scripts/ifcfg* | gawk -F ':' '{print $1}' | head -n 1"
|
2017-09-26 17:23:25 +00:00
|
|
|
when: ansible_default_ipv4.gateway is defined
|
2017-09-20 05:48:30 +00:00
|
|
|
register: ifcfg_gw_mac
|
|
|
|
ignore_errors: True
|
|
|
|
changed_when: False
|
|
|
|
|
2017-10-27 17:26:27 +00:00
|
|
|
- name: Set has ifcfg gw based on macaddress if found
|
2017-09-20 05:48:30 +00:00
|
|
|
set_fact:
|
|
|
|
has_ifcfg_gw: "{{ ifcfg_gw_mac.stdout|trim }}"
|
2017-10-23 09:29:22 +00:00
|
|
|
when: ifcfg_gw_mac is defined and ifcfg_gw_mac.changed and ifcfg_gw_mac.stdout != ""
|
2017-09-20 05:48:30 +00:00
|
|
|
|
2017-09-26 17:23:25 +00:00
|
|
|
# could use something else - Can Fail
|
2017-10-27 17:26:27 +00:00
|
|
|
- name: Find WiFi gateway config if present - Can Fail
|
2017-09-20 05:48:30 +00:00
|
|
|
shell: egrep -rn ESSID /etc/sysconfig/network-scripts/ifcfg* | gawk -F ':' '{print $1}' | gawk -F '/' '{print $5}'
|
|
|
|
register: ifcfg_WAN_wifi
|
2017-09-22 04:17:20 +00:00
|
|
|
ignore_errors: True
|
2017-09-20 05:48:30 +00:00
|
|
|
|
|
|
|
#returns file name
|
|
|
|
- name: Setting has_wifi_gw based on ESSID if found - Can Fail
|
|
|
|
set_fact:
|
|
|
|
has_wifi_gw: "{{ item|trim }}"
|
|
|
|
when: ifcfg_WAN_wifi.changed and item|trim != ""
|
|
|
|
with_items:
|
2018-10-08 21:51:15 +00:00
|
|
|
- "{{ ifcfg_WAN_wifi.stdout_lines }}"
|
2017-09-20 05:48:30 +00:00
|
|
|
|
2017-10-27 17:26:27 +00:00
|
|
|
- name: Finding device for WiFi AP gateway - Can Fail
|
2017-09-20 05:48:30 +00:00
|
|
|
shell: egrep -rn DEVICE /etc/sysconfig/network-scripts/{{ has_wifi_gw }} | gawk -F '=' '{print $2}'
|
2017-09-26 17:23:25 +00:00
|
|
|
when: has_wifi_gw != "none" and has_ifcfg_gw != "none"
|
2017-09-20 05:48:30 +00:00
|
|
|
register: AP_device
|
2017-09-22 04:17:20 +00:00
|
|
|
ignore_errors: True
|
2017-09-20 05:48:30 +00:00
|
|
|
|
2017-10-27 17:26:27 +00:00
|
|
|
- name: Setting WiFi device
|
2017-09-20 05:48:30 +00:00
|
|
|
set_fact:
|
|
|
|
ap_device: "{{ AP_device.stdout }}"
|
|
|
|
when: AP_device.stdout is defined and AP_device.stdout != ""
|
|
|
|
|
|
|
|
#unused
|
|
|
|
#- name: Get a list of ifcfg files to delete - Can Fail
|
|
|
|
# shell: "ls -1 /etc/sysconfig/network-scripts/ifcfg-* | grep -v -e ifcfg-lo -e ifcfg-WAN -e {{ has_wifi_gw }}"
|
|
|
|
# register: ifcfg_files
|
|
|
|
# changed_when: False
|
|
|
|
# ignore_errors: True
|
|
|
|
# when: num_lan_interfaces >= "1" or iiab_wireless_lan_iface != "none"
|