mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
isolate redhat network detection
This commit is contained in:
parent
ad04450565
commit
3d1efee5a6
2 changed files with 91 additions and 76 deletions
|
@ -20,22 +20,6 @@
|
||||||
device_gw2: "{{ prior_gw.stdout }}"
|
device_gw2: "{{ prior_gw.stdout }}"
|
||||||
when: prior_gw is defined and prior_gw.stdout != ""
|
when: prior_gw is defined and prior_gw.stdout != ""
|
||||||
|
|
||||||
- name: Checking for ifcfg-WAN file
|
|
||||||
stat: path=/etc/sysconfig/network-scripts/ifcfg-WAN
|
|
||||||
register: has_ifcfg_WAN
|
|
||||||
|
|
||||||
- name: Setting ifcfg-WAN True
|
|
||||||
set_fact:
|
|
||||||
has_WAN: True
|
|
||||||
when: has_ifcfg_WAN.stat.exists
|
|
||||||
|
|
||||||
# DETECT -- gateway and wireless
|
|
||||||
- name: Get a list of slaves from previous config
|
|
||||||
shell: "egrep -rn BRIDGE=br0 /etc/sysconfig/network-scripts/ifcfg-* | awk -F'[-:]' '{print $3}'"
|
|
||||||
register: ifcfg_slaves
|
|
||||||
ignore_errors: True
|
|
||||||
changed_when: False
|
|
||||||
|
|
||||||
# Discover do we have a gateway? -- if ansible detects gateway, becomes WAN candidate
|
# Discover do we have a gateway? -- if ansible detects gateway, becomes WAN candidate
|
||||||
- name: Finding gateway
|
- name: Finding gateway
|
||||||
set_fact:
|
set_fact:
|
||||||
|
@ -74,59 +58,9 @@
|
||||||
device_gw: "{{ discovered_wan_iface }}"
|
device_gw: "{{ discovered_wan_iface }}"
|
||||||
when: discovered_wan_iface != "none"
|
when: discovered_wan_iface != "none"
|
||||||
|
|
||||||
# returns list of paths
|
- name: RedHat Network detection
|
||||||
- name: Find gateway config based on device
|
include: detected_redhat.yml
|
||||||
shell: "egrep -rn {{ device_gw }} /etc/sysconfig/network-scripts/ifcfg* | awk -F ':' '{print $1}'"
|
when: is_redhat
|
||||||
register: ifcfg_gw_device
|
|
||||||
ignore_errors: True
|
|
||||||
changed_when: False
|
|
||||||
when: device_gw != "none"
|
|
||||||
|
|
||||||
# last match wins
|
|
||||||
- name: Setting has ifcfg gw based on device if found
|
|
||||||
set_fact:
|
|
||||||
has_ifcfg_gw: "{{ item|trim }}"
|
|
||||||
ignore_errors: True
|
|
||||||
when: ifcfg_gw_device.stdout_lines is defined and item|trim != "" and item|trim != "/etc/sysconfig/network-scripts/ifcfg-LAN"
|
|
||||||
with_items:
|
|
||||||
- "{{ ifcfg_gw_device.stdout_lines }}"
|
|
||||||
|
|
||||||
# returns path
|
|
||||||
- name: Find active gateway config based on macaddress
|
|
||||||
shell: "egrep -irn {{ ansible_default_ipv4.macaddress }} /etc/sysconfig/network-scripts/ifcfg* | awk -F ':' '{print $1}' | head -n 1"
|
|
||||||
register: ifcfg_gw_mac
|
|
||||||
ignore_errors: True
|
|
||||||
changed_when: False
|
|
||||||
when: 'ansible_default_ipv4.gateway is defined'
|
|
||||||
|
|
||||||
- name: Set has ifcfg gw based on on macaddress if found
|
|
||||||
set_fact:
|
|
||||||
has_ifcfg_gw: "{{ ifcfg_gw_mac.stdout|trim }}"
|
|
||||||
when: ifcfg_gw_mac.stdout is defined and ifcfg_gw_mac.stdout != ""
|
|
||||||
|
|
||||||
# could use something else
|
|
||||||
- name: Find wifi gateway config if present
|
|
||||||
shell: egrep -rn ESSID /etc/sysconfig/network-scripts/ifcfg* | awk -F ':' '{print $1}' | awk -F '/' '{print $5}'
|
|
||||||
register: ifcfg_WAN_wifi
|
|
||||||
ignore_errors: True
|
|
||||||
|
|
||||||
#returns file name
|
|
||||||
- name: Setting has_wifi_gw based on ESSID if found
|
|
||||||
set_fact:
|
|
||||||
has_wifi_gw: "{{ item|trim }}"
|
|
||||||
when: ifcfg_WAN_wifi.changed and item|trim != ""
|
|
||||||
with_items:
|
|
||||||
- "{{ ifcfg_WAN_wifi.stdout_lines }}"
|
|
||||||
|
|
||||||
- name: Finding device for wifi AP gateway
|
|
||||||
shell: egrep -rn DEVICE /etc/sysconfig/network-scripts/{{ has_wifi_gw }} | awk -F '=' '{print $2}'
|
|
||||||
register: AP_device
|
|
||||||
when: has_wifi_gw != "none" and has_ifcfg_gw != "none"
|
|
||||||
|
|
||||||
- name: Setting wifi device
|
|
||||||
set_fact:
|
|
||||||
ap_device: "{{ AP_device.stdout }}"
|
|
||||||
when: AP_device.stdout is defined and AP_device.stdout != ""
|
|
||||||
|
|
||||||
# WIRELESS -- if any wireless is detected as gateway, it becomes WAN
|
# WIRELESS -- if any wireless is detected as gateway, it becomes WAN
|
||||||
- name: Look for any wireless interfaces
|
- name: Look for any wireless interfaces
|
||||||
|
@ -222,13 +156,8 @@
|
||||||
when: discovered_wireless_iface != "none" and discovered_wireless_iface != iiab_wan_iface
|
when: discovered_wireless_iface != "none" and discovered_wireless_iface != iiab_wan_iface
|
||||||
|
|
||||||
#unused
|
#unused
|
||||||
- name: Get a list of ifcfg files to delete
|
#- name: Get a list of ifcfg files to delete
|
||||||
shell: "ls -1 /etc/sysconfig/network-scripts/ifcfg-* | grep -v -e ifcfg-lo -e ifcfg-WAN -e {{ has_wifi_gw }}"
|
# moved to detected_redhat
|
||||||
register: ifcfg_files
|
|
||||||
changed_when: False
|
|
||||||
ignore_errors: True
|
|
||||||
when: num_lan_interfaces >= "1" or iiab_wireless_lan_iface != "none"
|
|
||||||
#
|
|
||||||
|
|
||||||
# use value only if present
|
# use value only if present
|
||||||
- name: Setting detected lan
|
- name: Setting detected lan
|
||||||
|
|
86
roles/1-prep/tasks/detected_redhat.yml
Normal file
86
roles/1-prep/tasks/detected_redhat.yml
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
# temp
|
||||||
|
- name: temp placekeeper
|
||||||
|
set_fact:
|
||||||
|
first_run: False
|
||||||
|
|
||||||
|
- name: Checking for ifcfg-WAN file - Can Fail
|
||||||
|
stat: path=/etc/sysconfig/network-scripts/ifcfg-WAN
|
||||||
|
register: has_ifcfg_WAN
|
||||||
|
when: not first_run
|
||||||
|
|
||||||
|
- name: Setting ifcfg-WAN True
|
||||||
|
set_fact:
|
||||||
|
has_WAN: True
|
||||||
|
when: has_ifcfg_WAN.stat.exists
|
||||||
|
|
||||||
|
# DETECT -- gateway and wireless
|
||||||
|
- 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}'"
|
||||||
|
register: ifcfg_slaves
|
||||||
|
ignore_errors: True
|
||||||
|
changed_when: False
|
||||||
|
when: not first_run
|
||||||
|
|
||||||
|
# returns list of paths
|
||||||
|
- name: Find gateway config based on device
|
||||||
|
shell: "egrep -rn {{ device_gw }} /etc/sysconfig/network-scripts/ifcfg* | gawk -F ':' '{print $1}'"
|
||||||
|
register: ifcfg_gw_device
|
||||||
|
ignore_errors: True
|
||||||
|
changed_when: False
|
||||||
|
when: not first_run and device_gw != "none"
|
||||||
|
|
||||||
|
# last match wins
|
||||||
|
- name: Setting has ifcfg gw based on device if found
|
||||||
|
set_fact:
|
||||||
|
has_ifcfg_gw: "{{ item|trim }}"
|
||||||
|
ignore_errors: True
|
||||||
|
when: ifcfg_gw_device.stdout_lines is defined and item|trim != "" and item|trim != "/etc/sysconfig/network-scripts/ifcfg-LAN"
|
||||||
|
with_items:
|
||||||
|
- "{{ ifcfg_gw_device.stdout_lines }}"
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
register: ifcfg_gw_mac
|
||||||
|
ignore_errors: True
|
||||||
|
changed_when: False
|
||||||
|
when: ansible_default_ipv4.gateway is defined
|
||||||
|
|
||||||
|
- name: Set has ifcfg gw based on on macaddress if found
|
||||||
|
set_fact:
|
||||||
|
has_ifcfg_gw: "{{ ifcfg_gw_mac.stdout|trim }}"
|
||||||
|
when: ifcfg_gw_mac.changed and ifcfg_gw_mac.stdout != ""
|
||||||
|
|
||||||
|
# could use something else
|
||||||
|
- name: Find wifi gateway config if present - Can Fail
|
||||||
|
shell: egrep -rn ESSID /etc/sysconfig/network-scripts/ifcfg* | gawk -F ':' '{print $1}' | gawk -F '/' '{print $5}'
|
||||||
|
ignore_errors: True
|
||||||
|
register: ifcfg_WAN_wifi
|
||||||
|
|
||||||
|
#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:
|
||||||
|
- "{{ ifcfg_WAN_wifi.stdout_lines }}"
|
||||||
|
|
||||||
|
- name: Finding device for wifi AP gateway - Can Fail
|
||||||
|
shell: egrep -rn DEVICE /etc/sysconfig/network-scripts/{{ has_wifi_gw }} | gawk -F '=' '{print $2}'
|
||||||
|
ignore_errors: True
|
||||||
|
register: AP_device
|
||||||
|
when: has_wifi_gw != "none" and has_ifcfg_gw != "none"
|
||||||
|
|
||||||
|
- name: Setting wifi device
|
||||||
|
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"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue