mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Merge pull request #554 from jvonau/U17-2
U17-2: refine network for Ubuntu 18.04 LTS daily builds
This commit is contained in:
commit
3a729396f0
14 changed files with 235 additions and 118 deletions
|
@ -4,7 +4,6 @@ wireless_lan_present: False
|
|||
strict_networking: False
|
||||
iiab_demo_mode: False
|
||||
gui_static_wan: False
|
||||
has_NM: False
|
||||
|
||||
# Set defaults for discovery process as strings
|
||||
wifi1: "not found-1"
|
||||
|
@ -29,6 +28,8 @@ has_wifi_gw: "none"
|
|||
#Debian
|
||||
dhcpcd_result: ""
|
||||
wan_in_interfaces: False
|
||||
network_manager_active: False
|
||||
systemd_networkd_active: False
|
||||
|
||||
# The values here are default local variables.
|
||||
gui_wan_iface: "unset"
|
||||
|
|
39
roles/network/tasks/NM-debian.yml
Normal file
39
roles/network/tasks/NM-debian.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
# NM-debian.yml
|
||||
- name: Stopping services
|
||||
include_tasks: down-debian.yml
|
||||
|
||||
# provide keyfile layout like the XO's used way back.
|
||||
- name: Create uuid for NM's keyfile store
|
||||
shell: uuidgen
|
||||
register: uuid_response
|
||||
|
||||
- name: Put the uuid in place
|
||||
set_fact:
|
||||
gen_uuid: "{{ uuid_response.stdout_lines[0] }}"
|
||||
|
||||
# NM might have a watcher on this path and we don't have to restart NM
|
||||
- name: Copy the bridge script for NetworkManager
|
||||
template:
|
||||
dest: /etc/NetworkManager/system-connections/
|
||||
src: network/bridge-br0
|
||||
|
||||
- name: Reload systemd
|
||||
shell: systemctl daemon-reload
|
||||
|
||||
- name: Restart the NetworkManager service
|
||||
service:
|
||||
name: network-manager
|
||||
state: restarted
|
||||
when: not nobridge is defined and not no_net_restart
|
||||
|
||||
- name: Restart hostapd when WiFi is present
|
||||
service:
|
||||
name: hostapd
|
||||
state: restarted
|
||||
when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance"
|
||||
|
||||
- name: dhcp_server may be affected - starting - user choice
|
||||
service:
|
||||
name: "{{ dhcp_service2 }}"
|
||||
state: started
|
||||
when: iiab_network_mode != "Appliance"
|
|
@ -9,7 +9,7 @@
|
|||
# 4. In lan_controller: wan is off, eth0 and wlan0 under br0
|
||||
# 5. In gateway: eth0 is wan, and wlan0 is under br0 (only one adapter under br0)
|
||||
# 6. As a slight concess to auto config, if eth1 exists, make it wan, and force gateway
|
||||
|
||||
|
||||
#- name: In upgrade from earlier IIAB 6.2, delete the resolvconf
|
||||
# package: name=resolvconf
|
||||
# state=absent
|
||||
|
@ -37,7 +37,7 @@
|
|||
- name: Copy the bridge script
|
||||
template: dest=/etc/network/interfaces.d/iiab
|
||||
src=network/systemd.j2
|
||||
when: not is_rpi and not has_NM and (iiab_lan_iface == "br0" or wan_ip != "dhcp")
|
||||
when: not is_rpi and (iiab_lan_iface == "br0" or wan_ip != "dhcp")
|
||||
|
||||
- name: Copy the bridge script for RPi
|
||||
template: dest=/etc/network/interfaces.d/iiab
|
||||
|
@ -57,34 +57,6 @@
|
|||
service: name=dnsmasq state=stopped
|
||||
when: dnsmasq_install
|
||||
|
||||
# do this
|
||||
#- name: Copy NetworkManager.conf for has_NM
|
||||
# template: dest=/etc/NetworkManager/NetworkManager.conf
|
||||
# src=network/NetworkManager.conf
|
||||
# when: has_NM and iiab_lan_iface == "br0"
|
||||
|
||||
#- name: Copy the bridge script for has_NM
|
||||
# template: dest=/etc/network/interfaces
|
||||
# src=network/systemd.j2
|
||||
# when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0"
|
||||
|
||||
# or provide keyfile layout like the XO's used way back.
|
||||
- name: Create uuid for NM
|
||||
shell: uuidgen
|
||||
register: uuid_response
|
||||
when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0"
|
||||
|
||||
- name: Put the uuid in place
|
||||
set_fact:
|
||||
gen_uuid: "{{ uuid_response.stdout_lines[0] }}"
|
||||
when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0"
|
||||
|
||||
# NM might have a watcher on this path and we don't have to restart NM
|
||||
- name: Copy the bridge script for has_NM
|
||||
template: dest=/etc/NetworkManager/system-connections/
|
||||
src=network/bridge-br0
|
||||
when: has_NM and not wan_in_interfaces and iiab_lan_iface == "br0"
|
||||
|
||||
- name: Reload systemd
|
||||
shell: systemctl daemon-reload
|
||||
|
||||
|
@ -95,8 +67,8 @@
|
|||
|
||||
- name: Restart the networking service
|
||||
service: name=networking state=restarted
|
||||
when: not nobridge is defined and not has_NM and not no_net_restart
|
||||
|
||||
when: not nobridge is defined and not no_net_restart
|
||||
|
||||
- name: Restart hostapd when WiFi is present
|
||||
service: name=hostapd state=restarted
|
||||
when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance"
|
||||
|
|
|
@ -21,7 +21,17 @@
|
|||
|
||||
- name: Setting dhcpcd_test results
|
||||
set_fact:
|
||||
dhcpcd_result: '{{ ansible_local.local_facts.dhcpcd }}'
|
||||
dhcpcd_result: "{{ ansible_local.local_facts.dhcpcd }}"
|
||||
|
||||
- name: Setting systemd_networkd results
|
||||
set_fact:
|
||||
systemd_networkd_active: True
|
||||
when: 'ansible_local.local_facts.systemd_networkd == "enabled"'
|
||||
|
||||
- name: Setting network_manager results
|
||||
set_fact:
|
||||
network_manager_active: True
|
||||
when: 'ansible_local.local_facts.network_manager == "enabled"'
|
||||
|
||||
- name: Check /etc/network/interfaces for gateway
|
||||
shell: grep {{ device_gw }} /etc/network/interfaces | wc -l
|
||||
|
@ -185,6 +195,10 @@
|
|||
value: '{{ device_gw2 }}'
|
||||
- option: 'dhcpcd_result'
|
||||
value: '{{ dhcpcd_result }}'
|
||||
- option: 'network_manager_active'
|
||||
value: '{{ network_manager_active }}'
|
||||
- option: 'systemd_networkd_active'
|
||||
value: '{{ systemd_networkd_active }}'
|
||||
- option: 'wan_in_interfaces'
|
||||
value: '{{ wan_in_interfaces }}'
|
||||
- option: 'wireless_list_1(wifi1)'
|
||||
|
|
25
roles/network/tasks/down-debian.yml
Normal file
25
roles/network/tasks/down-debian.yml
Normal file
|
@ -0,0 +1,25 @@
|
|||
# down-debian.yml
|
||||
|
||||
#- name: Supply resolvconf.conf
|
||||
# template:
|
||||
# dest: /etc/resolvconf.conf
|
||||
# src: network/resolvconf.j2
|
||||
|
||||
- name: bind may be affected
|
||||
service:
|
||||
name: "{{ dns_service }}"
|
||||
state: stopped
|
||||
when: named_install and dnsmasq_enabled
|
||||
|
||||
# dhcpd_server release the interface
|
||||
- name: dhcpd_server may be affected - stopping dhcpd
|
||||
service:
|
||||
name: dhcpd
|
||||
state: stopped
|
||||
when: dhcpd_install
|
||||
|
||||
- name: dhcpd_server may be affected - stopping dnsmasq
|
||||
service:
|
||||
name: dnsmasq
|
||||
state: stopped
|
||||
when: dnsmasq_install
|
|
@ -84,23 +84,41 @@
|
|||
|
||||
#### end services
|
||||
#### Start network layout
|
||||
|
||||
- include_tasks: ifcfg_mods.yml
|
||||
- name: Redhat networking
|
||||
include_tasks: ifcfg_mods.yml
|
||||
tags:
|
||||
- network
|
||||
- network
|
||||
when: is_redhat and not installing
|
||||
|
||||
- include_tasks: debian.yml
|
||||
- name: NetworkManager in use
|
||||
include_tasks: NM-debian.yml
|
||||
tags:
|
||||
- network
|
||||
when: is_debuntu
|
||||
#and not is_rpi and not installing
|
||||
- network
|
||||
when: is_debuntu and network_manager_active
|
||||
#and not installing
|
||||
|
||||
#- include_tasks: rpi_debian.yml
|
||||
# tags:
|
||||
# - network
|
||||
# when: is_debuntu and is_rpi and not installing
|
||||
- name: systemd-networkd in use
|
||||
include_tasks: sysd-netd-debian.yml
|
||||
tags:
|
||||
- network
|
||||
when: is_debuntu and systemd_networkd_active
|
||||
#and not installing
|
||||
|
||||
- name: RPi's have dhcpcd in use
|
||||
include_tasks: rpi_debian.yml
|
||||
tags:
|
||||
- network
|
||||
when: is_debuntu and is_rpi
|
||||
#and not installing
|
||||
|
||||
- name: Not RPi, Not NetworkManager, Not systemd-networkd in use
|
||||
include_tasks: debian.yml
|
||||
tags:
|
||||
- network
|
||||
when: not is_rpi and not network_manager_active and not systemd_networkd_active and is_debuntu
|
||||
#and not installing
|
||||
|
||||
# this is moving
|
||||
- name: Record iiab_wan_device
|
||||
lineinfile: dest=/etc/iiab/iiab.env
|
||||
regexp='^IIAB_WAN_DEVICE=*'
|
||||
|
@ -108,7 +126,7 @@
|
|||
state=present
|
||||
when: not installing
|
||||
tags:
|
||||
- network
|
||||
- network
|
||||
|
||||
- name: Record iiab_lan_device
|
||||
lineinfile: dest=/etc/iiab/iiab.env
|
||||
|
@ -117,15 +135,15 @@
|
|||
state=present
|
||||
when: not installing
|
||||
tags:
|
||||
- network
|
||||
- network
|
||||
|
||||
#### end network layout
|
||||
- include_tasks: restart.yml
|
||||
when: not installing
|
||||
tags:
|
||||
- network
|
||||
- named
|
||||
- dhcpd
|
||||
- dnsmasq
|
||||
- squid
|
||||
- AP
|
||||
- network
|
||||
- named
|
||||
- dhcpd
|
||||
- dnsmasq
|
||||
- squid
|
||||
- AP
|
||||
|
|
|
@ -5,78 +5,53 @@
|
|||
# a. gui_desired_network_role
|
||||
# b. hostapd_enabled
|
||||
# c. gui_static_wan_ip
|
||||
# 3. In appliance mode: wan (and wlan0) is either static or dhcp under br0, and hostapd off
|
||||
# 3. In appliance mode: wan is either wired dhcp/static or wlan0 and hostapd off
|
||||
# 4. In lan_controller: wan is off, eth0 and wlan0 under br0
|
||||
# 5. In gateway: eth0 is wan, and wlan0 is under br0 (only one adapter under br0)
|
||||
# 6. As a slight concess to auto config, if eth1 exists, make it wan, and force gateway
|
||||
# 5. In gateway: user gateway is wan, and wlan0 under br0 if not acting as
|
||||
# the gateway
|
||||
|
||||
- name: Raspbian stock has openresolv which is not available in Debian, off it
|
||||
package: name=openresolv
|
||||
state=absent
|
||||
- name: Supply resolvconf.conf
|
||||
template:
|
||||
dest: /etc/resolvconf.conf
|
||||
src: network/resolvconf.j2
|
||||
|
||||
- name: Get the stock resolv.conf manager
|
||||
package: name=resolvconf
|
||||
state=absent
|
||||
- name: Supply dhcpcd.conf
|
||||
template:
|
||||
dest: /etc/dhcpcd.conf
|
||||
src: network/dhcpcd.conf.j2
|
||||
|
||||
- name: On upgrade from earlier IIAB versions, remove /etc/network/interfaces.d/br0
|
||||
file: path=/etc/network/interfaces.d/br0
|
||||
state=absent
|
||||
when: iiab_lan_iface != "br0" and wan_ip == "dhcp"
|
||||
- name: Copy the bridge script for RPi
|
||||
template:
|
||||
dest: /etc/network/interfaces.d/iiab
|
||||
src: network/rpi.j2
|
||||
when: iiab_lan_iface == "br0"
|
||||
|
||||
- name: Default to 'LanController'
|
||||
set_fact:
|
||||
gui_desired_network_role: "LanController"
|
||||
when: not gui_desired_network_role is defined
|
||||
- name: Stopping services
|
||||
include_tasks: down-debian.yml
|
||||
|
||||
- name: Rewrite the /etc/network/interfaces file which we corrupted
|
||||
template: dest=/etc/network/interfaces
|
||||
src=network/interfaces.j2
|
||||
|
||||
- name: Supply our own dhcpcd.conf
|
||||
template: dest=/etc/dhcpcd.conf
|
||||
src=network/dhcpcd.conf.j2
|
||||
when: iiab_lan_iface == "br0" or wan_ip != "dhcp"
|
||||
|
||||
- name: Copy the network config script
|
||||
template: dest=/etc/network/interfaces.d/iiab
|
||||
src=network/systemd.j2
|
||||
register: interface
|
||||
when: iiab_lan_iface == "br0" or wan_ip != "dhcp"
|
||||
|
||||
- name: If this was a change, things need to shift
|
||||
service: name=hostapd state=stopped
|
||||
when: interface.changed
|
||||
|
||||
- name: dhcpcd may be affected
|
||||
service: name=dhcpcd state=stopped
|
||||
when: interface.changed
|
||||
|
||||
- name: Tear down any bridge and start fresh
|
||||
command: ip link set br0 down
|
||||
ignore_errors: True
|
||||
when: interface.changed
|
||||
|
||||
- name: And remove the device
|
||||
command: brctl delbr br0
|
||||
ignore_errors: True
|
||||
when: interface.changed
|
||||
|
||||
- name: Reset the eth0 interface
|
||||
command: ifdown eth0
|
||||
ignore_errors: True
|
||||
when: interface.changed
|
||||
|
||||
- name: Start up dhcpcd again
|
||||
service: name=dhcpcd state=started
|
||||
- name: Reload systemd
|
||||
shell: systemctl daemon-reload
|
||||
|
||||
# now pick up denyinterfaces
|
||||
- name: Restart dhcpcd
|
||||
service: name=dhcpcd state=restarted
|
||||
service:
|
||||
name: dhcpcd
|
||||
state: restarted
|
||||
|
||||
- name: Restart the networking service
|
||||
service: name=networking state=restarted
|
||||
service:
|
||||
name: networking
|
||||
enabled: yes
|
||||
state: restarted
|
||||
when: not nobridge is defined and not no_net_restart
|
||||
|
||||
#create lan br0 if lan_controller or gateway
|
||||
#create wan br0 if appliance
|
||||
#allocate wlan0 under br0 in all cases
|
||||
#allocate eth0 under br0 if appliance, alone if gateway
|
||||
- name: Restart hostapd when WiFi is present
|
||||
service:
|
||||
name: hostapd
|
||||
enabled: yes
|
||||
state: restarted
|
||||
when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance"
|
||||
|
||||
#- name: dhcp_server may be affected - starting - user choice
|
||||
# service: name={{ dhcp_service2 }} state=started
|
||||
# when: iiab_network_mode != "Appliance"
|
||||
|
|
40
roles/network/tasks/sysd-netd-debian.yml
Normal file
40
roles/network/tasks/sysd-netd-debian.yml
Normal file
|
@ -0,0 +1,40 @@
|
|||
# sysd-netd-debian.yml
|
||||
- name: Copy the bridge script - Creates br0
|
||||
template:
|
||||
dest: /etc/systemd/network/IIAB-Bridge.netdev
|
||||
src: network/systemd-br0.j2
|
||||
|
||||
- name: Copy the bridge script - Assigns IP address
|
||||
template:
|
||||
dest: /etc/systemd/network/IIAB-Bridge.network
|
||||
src: network/systemd-br0-network.j2
|
||||
|
||||
- name: Copy the bridge script - Assigns br0 wired slaves
|
||||
template:
|
||||
dest: /etc/systemd/network/IIAB-Slave.network
|
||||
src: network/systemd-br0-slave.j2
|
||||
when: iiab_wired_lan_iface is defined
|
||||
|
||||
- name: Stopping services
|
||||
include_tasks: down-debian.yml
|
||||
|
||||
- name: Reload systemd
|
||||
shell: systemctl daemon-reload
|
||||
|
||||
- name: Restart the systemd-networkd service
|
||||
service:
|
||||
name: systemd-networkd
|
||||
enabled: yes
|
||||
state: restarted
|
||||
when: not nobridge is defined and not no_net_restart
|
||||
|
||||
- name: Restart hostapd when WiFi is present
|
||||
service:
|
||||
name: hostapd
|
||||
enabled: yes
|
||||
state: restarted
|
||||
when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance"
|
||||
|
||||
#- name: dhcp_server may be affected - starting - user choice
|
||||
# service: name={{ dhcp_service2 }} state=started
|
||||
# when: iiab_network_mode != "Appliance"
|
15
roles/network/templates/network/systemd-br0-network.j2
Normal file
15
roles/network/templates/network/systemd-br0-network.j2
Normal file
|
@ -0,0 +1,15 @@
|
|||
# /etc/systemd/network/IIAB-Bridge.network
|
||||
[Match]
|
||||
Name=br0
|
||||
|
||||
[Network]
|
||||
Bridge=br0
|
||||
LinkLocalAddressing=no
|
||||
DNS={{ lan_ip }}
|
||||
Domains={{ iiab_domain }}
|
||||
|
||||
[Address]
|
||||
Address={{ lan_ip }}/19
|
||||
|
||||
[Route]
|
||||
Gateway=""
|
5
roles/network/templates/network/systemd-br0-slave.j2
Normal file
5
roles/network/templates/network/systemd-br0-slave.j2
Normal file
|
@ -0,0 +1,5 @@
|
|||
# /etc/systemd/network/IIAB-Slave.network
|
||||
[Match]
|
||||
Name={{ iiab_wired_lan_iface }}
|
||||
[Network]
|
||||
Bridge=br0
|
4
roles/network/templates/network/systemd-br0.j2
Normal file
4
roles/network/templates/network/systemd-br0.j2
Normal file
|
@ -0,0 +1,4 @@
|
|||
# /etc/systemd/network/IIAB-Bridge.netdev
|
||||
[NetDev]
|
||||
Name=br0
|
||||
Kind=bridge
|
|
@ -6,6 +6,7 @@ VERSION_ID=${VERSION_ID//\"/}
|
|||
VERSION_ID=${VERSION_ID%%.*}
|
||||
OS_VER=$OS-$VERSION_ID
|
||||
DHCPCD_PATH=`which dhcpcd`
|
||||
NM_PATH=`which NetworkManager`
|
||||
|
||||
case $OS_VER in
|
||||
"fedora-18" | \
|
||||
|
@ -59,10 +60,20 @@ if [ ! x$DHCPCD_PATH = x ]
|
|||
then
|
||||
DHCPCD=`systemctl is-enabled dhcpcd`
|
||||
fi
|
||||
# the check is debian family only is_redhad would use NetworkManager as the
|
||||
# service name.
|
||||
if [ ! x$NM_PATH = x ]
|
||||
then
|
||||
NM=`systemctl is-enabled network-manager`
|
||||
fi
|
||||
SYSD_NETD=`systemctl is-enabled systemd-networkd`
|
||||
|
||||
cat <<EOF
|
||||
{"phplib_dir" : "$PHPLIB_DIR",
|
||||
"stage" : "$STAGE",
|
||||
"dhcpcd" : "$DHCPCD",
|
||||
"network_manager" : "$NM",
|
||||
"systemd_networkd" : "$SYSD_NETD",
|
||||
"iiab_branch" : "$BRANCH",
|
||||
"iiab_commit" : "$COMMIT",
|
||||
"xo_model" : "$XO_VERSION",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
is_debuntu: True
|
||||
is_ubuntu: True
|
||||
has_NM: True
|
||||
dns_service: bind9
|
||||
dns_user: bind
|
||||
dhcp_service: isc-dhcp-server
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
is_debuntu: True
|
||||
is_ubuntu: True
|
||||
has_NM: True
|
||||
dns_service: bind9
|
||||
dns_user: bind
|
||||
dhcp_service: isc-dhcp-server
|
||||
|
|
Loading…
Add table
Reference in a new issue