mirror of
				https://github.com/iiab/iiab.git
				synced 2025-03-09 15:40:17 +00:00 
			
		
		
		
	hand merge of systemd-net with a rename 2
This commit is contained in:
		
							parent
							
								
									920ba0f364
								
							
						
					
					
						commit
						7e4ff797e5
					
				
					 9 changed files with 80 additions and 37 deletions
				
			
		| 
						 | 
					@ -4,7 +4,6 @@ wireless_lan_present: False
 | 
				
			||||||
strict_networking: False
 | 
					strict_networking: False
 | 
				
			||||||
iiab_demo_mode: False
 | 
					iiab_demo_mode: False
 | 
				
			||||||
gui_static_wan: False
 | 
					gui_static_wan: False
 | 
				
			||||||
has_NM: False
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set defaults for discovery process as strings
 | 
					# Set defaults for discovery process as strings
 | 
				
			||||||
wifi1: "not found-1"
 | 
					wifi1: "not found-1"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@
 | 
				
			||||||
    name: network-manager
 | 
					    name: network-manager
 | 
				
			||||||
    state: restarted
 | 
					    state: restarted
 | 
				
			||||||
  when: not nobridge is defined and not no_net_restart
 | 
					  when: not nobridge is defined and not no_net_restart
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
- name: Restart hostapd when WiFi is present
 | 
					- name: Restart hostapd when WiFi is present
 | 
				
			||||||
  service:
 | 
					  service:
 | 
				
			||||||
    name: hostapd
 | 
					    name: hostapd
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@
 | 
				
			||||||
#   4. In lan_controller: wan is off, eth0 and wlan0 under br0
 | 
					#   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)
 | 
					#   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
 | 
					#   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
 | 
					#- name: In upgrade from earlier IIAB 6.2, delete the resolvconf
 | 
				
			||||||
#  package: name=resolvconf
 | 
					#  package: name=resolvconf
 | 
				
			||||||
#           state=absent
 | 
					#           state=absent
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@
 | 
				
			||||||
- name: Copy the bridge script
 | 
					- name: Copy the bridge script
 | 
				
			||||||
  template: dest=/etc/network/interfaces.d/iiab
 | 
					  template: dest=/etc/network/interfaces.d/iiab
 | 
				
			||||||
            src=network/systemd.j2
 | 
					            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
 | 
					- name: Copy the bridge script for RPi
 | 
				
			||||||
  template: dest=/etc/network/interfaces.d/iiab
 | 
					  template: dest=/etc/network/interfaces.d/iiab
 | 
				
			||||||
| 
						 | 
					@ -57,34 +57,6 @@
 | 
				
			||||||
  service: name=dnsmasq state=stopped
 | 
					  service: name=dnsmasq state=stopped
 | 
				
			||||||
  when: dnsmasq_install
 | 
					  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
 | 
					- name: Reload systemd
 | 
				
			||||||
  shell: systemctl daemon-reload
 | 
					  shell: systemctl daemon-reload
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,8 +67,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Restart the networking service
 | 
					- name: Restart the networking service
 | 
				
			||||||
  service: name=networking  state=restarted
 | 
					  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
 | 
					- name: Restart hostapd when WiFi is present
 | 
				
			||||||
  service: name=hostapd state=restarted
 | 
					  service: name=hostapd state=restarted
 | 
				
			||||||
  when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance"
 | 
					  when: iiab_wireless_lan_iface is defined and hostapd_enabled and iiab_network_mode != "Appliance"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,8 @@
 | 
				
			||||||
- name: Setting dhcpcd_test results
 | 
					- name: Setting dhcpcd_test results
 | 
				
			||||||
  set_fact:
 | 
					  set_fact:
 | 
				
			||||||
    dhcpcd_result: '{{ ansible_local.local_facts.dhcpcd }}'
 | 
					    dhcpcd_result: '{{ ansible_local.local_facts.dhcpcd }}'
 | 
				
			||||||
 | 
					    systemd_networkd_result: '{{ ansible_local.local_facts.systemd_networkd }}'
 | 
				
			||||||
 | 
					    network_manager_result: '{{ ansible_local.local_facts.network_manager }}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Check /etc/network/interfaces for gateway
 | 
					- name: Check /etc/network/interfaces for gateway
 | 
				
			||||||
  shell: grep {{ device_gw }} /etc/network/interfaces | wc -l
 | 
					  shell: grep {{ device_gw }} /etc/network/interfaces | wc -l
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,13 +93,13 @@
 | 
				
			||||||
- include_tasks: NM-debian.yml
 | 
					- include_tasks: NM-debian.yml
 | 
				
			||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
    - network
 | 
					    - network
 | 
				
			||||||
  when: is_debuntu and has_NM
 | 
					  when: is_debuntu and network_manager_result == "enabled"
 | 
				
			||||||
#and not installing
 | 
					#and not installing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- include_tasks: debian.yml
 | 
					- include_tasks: sysd-net-debian.yml
 | 
				
			||||||
  tags:
 | 
					  tags:
 | 
				
			||||||
    - network
 | 
					    - network
 | 
				
			||||||
  when: is_debuntu and not is_rpi
 | 
					  when: is_debuntu and systemd_network_result == "enabled"
 | 
				
			||||||
#and not installing
 | 
					#and not installing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- include_tasks: rpi_debian.yml
 | 
					- include_tasks: rpi_debian.yml
 | 
				
			||||||
| 
						 | 
					@ -108,6 +108,12 @@
 | 
				
			||||||
  when: is_debuntu and is_rpi
 | 
					  when: is_debuntu and is_rpi
 | 
				
			||||||
#and not installing
 | 
					#and not installing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- include_tasks: debian.yml
 | 
				
			||||||
 | 
					  tags:
 | 
				
			||||||
 | 
					    - network
 | 
				
			||||||
 | 
					  when: not is_rpi and network_manager_result != "enabled" and systemd_network_result != "enabled" and is_debuntu
 | 
				
			||||||
 | 
					#and not installing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Record iiab_wan_device
 | 
					- name: Record iiab_wan_device
 | 
				
			||||||
  lineinfile: dest=/etc/iiab/iiab.env
 | 
					  lineinfile: dest=/etc/iiab/iiab.env
 | 
				
			||||||
              regexp='^IIAB_WAN_DEVICE=*'
 | 
					              regexp='^IIAB_WAN_DEVICE=*'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										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
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue