Rozdělení do skupin DSA a swconfig, úprava role network
This commit is contained in:
@@ -1,36 +1,35 @@
|
|||||||
device_bridge_port: "{{ ansible_facts.openwrt_interfaces.mgmnt.device | regex_search('eth[0-9]+|wan') }}"
|
|
||||||
|
|
||||||
device_2g_radio: "{{ (ansible_facts.openwrt_wireless | dict2items | selectattr('value.config.band', 'equalto', '2g') | map(attribute='key') | first) | default('none') }}"
|
device_2g_radio: "{{ (ansible_facts.openwrt_wireless | dict2items | selectattr('value.config.band', 'equalto', '2g') | map(attribute='key') | first) | default('none') }}"
|
||||||
device_5g_radio: "{{ (ansible_facts.openwrt_wireless | dict2items | selectattr('value.config.band', 'equalto', '5g') | map(attribute='key') | first) | default('none') }}"
|
device_5g_radio: "{{ (ansible_facts.openwrt_wireless | dict2items | selectattr('value.config.band', 'equalto', '5g') | map(attribute='key') | first) | default('none') }}"
|
||||||
|
|
||||||
network_devices:
|
network_devices:
|
||||||
- id: "@device[1]"
|
- name: "br-vlan129"
|
||||||
name: "br-vlan129"
|
|
||||||
state: "present"
|
state: "present"
|
||||||
type: "bridge"
|
type: "bridge"
|
||||||
ports: ["{{ device_bridge_port }}.129"]
|
ports: ["{{ device_bridge_port }}.129"]
|
||||||
- id: "@device[2]"
|
- name: "br-vlan137"
|
||||||
name: "br-vlan137"
|
|
||||||
state: "present"
|
state: "present"
|
||||||
type: "bridge"
|
type: "bridge"
|
||||||
ports: ["{{ device_bridge_port }}.137"]
|
ports: ["{{ device_bridge_port }}.137"]
|
||||||
- id: "@device[3]"
|
- name: "br-vlan145"
|
||||||
name: "br-vlan145"
|
|
||||||
state: "present"
|
state: "present"
|
||||||
type: "bridge"
|
type: "bridge"
|
||||||
ports: ["{{ device_bridge_port }}.145"]
|
ports: ["{{ device_bridge_port }}.145"]
|
||||||
- id: "@device[4]"
|
- name: "br-free"
|
||||||
name: "br-free"
|
|
||||||
state: "present"
|
state: "present"
|
||||||
type: "bridge"
|
type: "bridge"
|
||||||
ports: ["{{ device_bridge_port }}.152"]
|
ports: ["{{ device_bridge_port }}.152"]
|
||||||
- id: "@device[5]"
|
- name: "br-oldaurora"
|
||||||
name: "br-oldaurora"
|
|
||||||
state: "present"
|
state: "present"
|
||||||
type: "bridge"
|
type: "bridge"
|
||||||
ports: ["{{ device_bridge_port }}.128"]
|
ports: ["{{ device_bridge_port }}.128"]
|
||||||
|
|
||||||
network_interfaces:
|
network_interfaces:
|
||||||
|
- id: "mgmnt"
|
||||||
|
proto: "static"
|
||||||
|
device: "{{ device_bridge_port }}.99"
|
||||||
|
ipaddr: "{{ device_ip_address }}/24"
|
||||||
|
gateway: "{{ device_ip_address | regex_replace('\\.[0-9]+$', '.1') }}"
|
||||||
|
dns: ["{{ device_ip_address | regex_replace('\\.[0-9]+$', '.1') }}"]
|
||||||
- id: "hoste_wifi"
|
- id: "hoste_wifi"
|
||||||
proto: "none"
|
proto: "none"
|
||||||
device: "br-vlan129"
|
device: "br-vlan129"
|
||||||
|
|||||||
1
group_vars/dsa.yml
Normal file
1
group_vars/dsa.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
device_bridge_port: "{{ network_devices_append[0].name }}"
|
||||||
1
group_vars/swconfig.yml
Normal file
1
group_vars/swconfig.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
device_bridge_port: "{{ ansible_facts.openwrt_interfaces.mgmnt.device | regex_search('eth[0-9]+') }}"
|
||||||
@@ -1,24 +1,6 @@
|
|||||||
device_ip_address: "10.11.99.4"
|
device_ip_address: "10.11.99.4"
|
||||||
device_hostname: "ap-outdoor"
|
device_hostname: "ap-outdoor"
|
||||||
|
|
||||||
# network_switch_vlans:
|
|
||||||
# - id: "@switch_vlan[1]"
|
|
||||||
# vlan: "128"
|
|
||||||
# ports: "0t 1t 2 3t 4 5"
|
|
||||||
# description: "hoste"
|
|
||||||
# - id: "@switch_vlan[2]"
|
|
||||||
# vlan: "136"
|
|
||||||
# ports: "0t 1t"
|
|
||||||
# description: "studenti"
|
|
||||||
# - id: "@switch_vlan[3]"
|
|
||||||
# vlan: "144"
|
|
||||||
# ports: "0t 1t 3t"
|
|
||||||
# description: "ucitele"
|
|
||||||
# - id: "@switch_vlan[4]"
|
|
||||||
# vlan: "152"
|
|
||||||
# ports: "0t 1t"
|
|
||||||
# description: "free"
|
|
||||||
|
|
||||||
# wireless_devices:
|
# wireless_devices:
|
||||||
# - id: ""
|
# - id: ""
|
||||||
# channel: "6"
|
# channel: "6"
|
||||||
|
|||||||
@@ -1,52 +1,36 @@
|
|||||||
device_ip_address: "10.11.99.2"
|
device_ip_address: "10.11.99.2"
|
||||||
device_hostname: ""
|
device_hostname: "ap-pokoj"
|
||||||
|
|
||||||
network_dsa_switch_vlans:
|
network_devices_append:
|
||||||
- id: "@switch_vlan[1]"
|
- name: "br0"
|
||||||
vlan: "128"
|
state: "present"
|
||||||
ports: "0t 6t 1 2 3 4"
|
type: "bridge"
|
||||||
description: "hoste"
|
ports: ["wan", "lan1", "lan2", "lan3"]
|
||||||
- id: "@switch_vlan[2]"
|
network_bridge_vlan_filtering:
|
||||||
vlan: "129"
|
- vlan: "99"
|
||||||
ports: "0t 6t"
|
device: "{{ device_bridge_port }}"
|
||||||
description: "hoste_wifi"
|
ports: ["wan:t"]
|
||||||
- id: "@switch_vlan[3]"
|
- vlan: "128"
|
||||||
vlan: "136"
|
device: "{{ device_bridge_port }}"
|
||||||
ports: "0t 6t"
|
ports: ["wan:t", "lan1", "lan2:t"]
|
||||||
description: "studenti_lan"
|
- vlan: "129"
|
||||||
- id: "@switch_vlan[4]"
|
device: "{{ device_bridge_port }}"
|
||||||
vlan: "137"
|
ports: ["wan:t", "lan2:t"]
|
||||||
ports: "0t 6t"
|
- vlan: "136"
|
||||||
description: "studenti_wifi"
|
device: "{{ device_bridge_port }}"
|
||||||
- id: "@switch_vlan[5]"
|
ports: ["wan:t", "lan2:t"]
|
||||||
vlan: "144"
|
- vlan: "137"
|
||||||
ports: "0t 6t"
|
device: "{{ device_bridge_port }}"
|
||||||
description: "ucitele_lan"
|
ports: ["wan:t", "lan2:t"]
|
||||||
- id: "@switch_vlan[6]"
|
- vlan: "144"
|
||||||
vlan: "145"
|
device: "{{ device_bridge_port }}"
|
||||||
ports: "0t 6t"
|
ports: ["wan:t", "lan2:t"]
|
||||||
description: "ucitele_wifi"
|
- vlan: "145"
|
||||||
- id: "@switch_vlan[7]"
|
device: "{{ device_bridge_port }}"
|
||||||
vlan: "152"
|
ports: ["wan:t", "lan2:t"]
|
||||||
ports: "0t 6t"
|
- vlan: "152"
|
||||||
description: "free_wifi"
|
device: "{{ device_bridge_port }}"
|
||||||
# network_switch_vlans:
|
ports: ["wan:t", "lan2:t"]
|
||||||
# - id: "@switch_vlan[1]"
|
|
||||||
# vlan: "128"
|
|
||||||
# ports: "0t 1t 2 3t 4 5"
|
|
||||||
# description: "hoste"
|
|
||||||
# - id: "@switch_vlan[2]"
|
|
||||||
# vlan: "136"
|
|
||||||
# ports: "0t 1t"
|
|
||||||
# description: "studenti"
|
|
||||||
# - id: "@switch_vlan[3]"
|
|
||||||
# vlan: "144"
|
|
||||||
# ports: "0t 1t 3t"
|
|
||||||
# description: "ucitele"
|
|
||||||
# - id: "@switch_vlan[4]"
|
|
||||||
# vlan: "152"
|
|
||||||
# ports: "0t 1t"
|
|
||||||
# description: "free"
|
|
||||||
|
|
||||||
# wireless_devices:
|
# wireless_devices:
|
||||||
# - id: ""
|
# - id: ""
|
||||||
|
|||||||
@@ -1,39 +1,28 @@
|
|||||||
device_ip_address: "10.11.99.3"
|
device_ip_address: "10.11.99.3"
|
||||||
device_hostname: "ap-predsin"
|
device_hostname: "ap-predsin"
|
||||||
|
|
||||||
network_swconfig_switch_vlans:
|
network_swconfig:
|
||||||
- id: "@switch_vlan[1]"
|
- vlan: "128"
|
||||||
vlan: "128"
|
|
||||||
ports: "0t 1t 2"
|
ports: "0t 1t 2"
|
||||||
description: "hoste_lan"
|
description: "hoste_lan"
|
||||||
- id: "@switch_vlan[2]"
|
- vlan: "129"
|
||||||
vlan: "129"
|
|
||||||
ports: "0t 1t"
|
ports: "0t 1t"
|
||||||
description: "hoste_wifi"
|
description: "hoste_wifi"
|
||||||
- id: "@switch_vlan[3]"
|
- vlan: "136"
|
||||||
vlan: "136"
|
|
||||||
ports: "0t 1t"
|
ports: "0t 1t"
|
||||||
description: "studenti_lan"
|
description: "studenti_lan"
|
||||||
- id: "@switch_vlan[4]"
|
- vlan: "137"
|
||||||
vlan: "137"
|
|
||||||
ports: "0t 1t"
|
ports: "0t 1t"
|
||||||
description: "studenti_wifi"
|
description: "studenti_wifi"
|
||||||
- id: "@switch_vlan[5]"
|
- vlan: "144"
|
||||||
vlan: "144"
|
|
||||||
ports: "0t 1t"
|
ports: "0t 1t"
|
||||||
description: "ucitele_lan"
|
description: "ucitele_lan"
|
||||||
- id: "@switch_vlan[6]"
|
- vlan: "145"
|
||||||
vlan: "145"
|
|
||||||
ports: "0t 1t"
|
ports: "0t 1t"
|
||||||
description: "ucitele_wifi"
|
description: "ucitele_wifi"
|
||||||
- id: "@switch_vlan[7]"
|
- vlan: "152"
|
||||||
vlan: "152"
|
|
||||||
ports: "0t 1t"
|
ports: "0t 1t"
|
||||||
description: "free_wifi"
|
description: "free_wifi"
|
||||||
- id: "@switch_vlan[8]"
|
|
||||||
vlan: "199"
|
|
||||||
ports: "0t 1t"
|
|
||||||
description: "oldAurora"
|
|
||||||
|
|
||||||
wireless_devices:
|
wireless_devices:
|
||||||
- id: "{{ device_2g_radio }}"
|
- id: "{{ device_2g_radio }}"
|
||||||
|
|||||||
@@ -1,40 +1,33 @@
|
|||||||
device_ip_address: "10.11.99.6"
|
device_ip_address: "10.11.99.6"
|
||||||
device_hostname: "ap-vila-dole"
|
device_hostname: "ap-vila-dole"
|
||||||
|
|
||||||
network_swconfig_switch_vlans:
|
network_swconfig:
|
||||||
- id: "@switch_vlan[1]"
|
- vlan: "128"
|
||||||
vlan: "128"
|
|
||||||
ports: "0t 6t 1 2 3 4"
|
ports: "0t 6t 1 2 3 4"
|
||||||
description: "hoste"
|
description: "hoste"
|
||||||
- id: "@switch_vlan[2]"
|
- vlan: "129"
|
||||||
vlan: "129"
|
|
||||||
ports: "0t 6t"
|
ports: "0t 6t"
|
||||||
description: "hoste_wifi"
|
description: "hoste_wifi"
|
||||||
- id: "@switch_vlan[3]"
|
- vlan: "136"
|
||||||
vlan: "136"
|
|
||||||
ports: "0t 6t"
|
ports: "0t 6t"
|
||||||
description: "studenti_lan"
|
description: "studenti_lan"
|
||||||
- id: "@switch_vlan[4]"
|
- vlan: "137"
|
||||||
vlan: "137"
|
|
||||||
ports: "0t 6t"
|
ports: "0t 6t"
|
||||||
description: "studenti_wifi"
|
description: "studenti_wifi"
|
||||||
- id: "@switch_vlan[5]"
|
- vlan: "144"
|
||||||
vlan: "144"
|
|
||||||
ports: "0t 6t"
|
ports: "0t 6t"
|
||||||
description: "ucitele_lan"
|
description: "ucitele_lan"
|
||||||
- id: "@switch_vlan[6]"
|
- vlan: "145"
|
||||||
vlan: "145"
|
|
||||||
ports: "0t 6t"
|
ports: "0t 6t"
|
||||||
description: "ucitele_wifi"
|
description: "ucitele_wifi"
|
||||||
- id: "@switch_vlan[7]"
|
- vlan: "152"
|
||||||
vlan: "152"
|
|
||||||
ports: "0t 6t"
|
ports: "0t 6t"
|
||||||
description: "free_wifi"
|
description: "free_wifi"
|
||||||
|
|
||||||
wireless_devices:
|
wireless_devices:
|
||||||
- id: "{{ device_2g_radio }}"
|
- id: "{{ device_2g_radio }}"
|
||||||
channel: "13"
|
channel: "13"
|
||||||
txpower: "4"
|
txpower: "8"
|
||||||
|
|
||||||
# wireless_interfaces_override:
|
# wireless_interfaces_override:
|
||||||
# - ssid: "aurora"
|
# - ssid: "aurora"
|
||||||
|
|||||||
@@ -1,44 +1,36 @@
|
|||||||
device_ip_address: "10.11.99.5"
|
device_ip_address: "10.11.99.5"
|
||||||
device_hostname: "ap-vila-nahore"
|
device_hostname: "ap-vila-nahore"
|
||||||
|
|
||||||
network_swconfig_switch_vlans:
|
network_swconfig:
|
||||||
- id: "@switch_vlan[0]"
|
- vlan: "99"
|
||||||
vlan: "99"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "mgmnt"
|
description: "mgmnt"
|
||||||
- id: "@switch_vlan[1]"
|
- vlan: "128"
|
||||||
vlan: "128"
|
|
||||||
ports: "0t 6t 1 2t 3 4"
|
ports: "0t 6t 1 2t 3 4"
|
||||||
description: "hoste"
|
description: "hoste"
|
||||||
- id: "@switch_vlan[2]"
|
- vlan: "129"
|
||||||
vlan: "129"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "hoste_wifi"
|
description: "hoste_wifi"
|
||||||
- id: "@switch_vlan[3]"
|
- vlan: "136"
|
||||||
vlan: "136"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "studenti_lan"
|
description: "studenti_lan"
|
||||||
- id: "@switch_vlan[4]"
|
- vlan: "137"
|
||||||
vlan: "137"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "studenti_wifi"
|
description: "studenti_wifi"
|
||||||
- id: "@switch_vlan[5]"
|
- vlan: "144"
|
||||||
vlan: "144"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "ucitele_lan"
|
description: "ucitele_lan"
|
||||||
- id: "@switch_vlan[6]"
|
- vlan: "145"
|
||||||
vlan: "145"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "ucitele_wifi"
|
description: "ucitele_wifi"
|
||||||
- id: "@switch_vlan[7]"
|
- vlan: "152"
|
||||||
vlan: "152"
|
|
||||||
ports: "0t 6t 2t"
|
ports: "0t 6t 2t"
|
||||||
description: "free_wifi"
|
description: "free_wifi"
|
||||||
|
|
||||||
wireless_devices:
|
wireless_devices:
|
||||||
- id: "{{ device_2g_radio }}"
|
- id: "{{ device_2g_radio }}"
|
||||||
channel: "8"
|
channel: "8"
|
||||||
txpower: "4"
|
txpower: "8"
|
||||||
|
|
||||||
# wireless_interfaces_override:
|
# wireless_interfaces_override:
|
||||||
# - ssid: "aurora"
|
# - ssid: "aurora"
|
||||||
|
|||||||
@@ -5,9 +5,13 @@ openwrt:
|
|||||||
accessPoints:
|
accessPoints:
|
||||||
vars:
|
vars:
|
||||||
ansible_scp_extra_args: "-O"
|
ansible_scp_extra_args: "-O"
|
||||||
|
children:
|
||||||
|
dsa:
|
||||||
|
hosts:
|
||||||
|
ap_107c61992bd8:
|
||||||
|
ansible_host: "10.11.99.2"
|
||||||
|
swconfig:
|
||||||
hosts:
|
hosts:
|
||||||
# ap_c47154394838:
|
|
||||||
# ansible_host: "10.11.99.2"
|
|
||||||
ap_b04e26bbc7e3:
|
ap_b04e26bbc7e3:
|
||||||
ansible_host: "10.11.99.3"
|
ansible_host: "10.11.99.3"
|
||||||
ap_0c806307e88a:
|
ap_0c806307e88a:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
# Reload network service using nohup
|
# Reload network service
|
||||||
- name: Reload network
|
- name: Reload network
|
||||||
nohup:
|
ansible.builtin.service:
|
||||||
command: /etc/init.d/network restart
|
name: network
|
||||||
|
state: reloaded
|
||||||
@@ -1,42 +1,33 @@
|
|||||||
---
|
---
|
||||||
# Set state status for network device
|
# Set state status for network device
|
||||||
- name: Set state status for network device {{ item.id | default('@device[-1]') }}
|
- name: Set state status for network device {{ item.name }}
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
network_device_state: "{{ item.state | default('present') }}"
|
network_device_state: "{{ item.state | default('present') }}"
|
||||||
|
|
||||||
# Delete network device
|
# Delete network device
|
||||||
- name: Delete network device {{ item.id }}
|
- name: Delete network device {{ item.name }}
|
||||||
when: "'absent' in network_device_state"
|
when: "'absent' in network_device_state"
|
||||||
uci:
|
uci:
|
||||||
command: "absent"
|
command: "absent"
|
||||||
config: "network"
|
config: "network"
|
||||||
section: "{{ item.id }}"
|
|
||||||
type: "device"
|
type: "device"
|
||||||
|
find:
|
||||||
|
name: "{{ item.name | mandatory }}"
|
||||||
|
|
||||||
# Create and configure network device
|
# Create and configure network device
|
||||||
- name: Create and configure network device
|
- name: Create and configure network device
|
||||||
when: "'present' in network_device_state"
|
when: "'present' in network_device_state"
|
||||||
block:
|
|
||||||
# Create network device
|
|
||||||
- name: Create network device {{ item.id | default('@device[-1]') }}
|
|
||||||
uci:
|
uci:
|
||||||
command: "add"
|
command: "section"
|
||||||
config: "network"
|
config: "network"
|
||||||
section: "{{ item.id | default('@device[-1]') }}"
|
|
||||||
type: "device"
|
type: "device"
|
||||||
|
find:
|
||||||
# Configure network device
|
|
||||||
- name: Configure network device {{ item.id | default('@device[-1]') }}
|
|
||||||
uci:
|
|
||||||
command: "set"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id | default('@device[-1]') }}"
|
|
||||||
type: "device"
|
|
||||||
value:
|
|
||||||
name: "{{ item.name | default(omit) }}"
|
name: "{{ item.name | default(omit) }}"
|
||||||
|
value:
|
||||||
type: "{{ item.type | default(omit) }}"
|
type: "{{ item.type | default(omit) }}"
|
||||||
ports: "{{ item.ports | default([]) | join(' ') }}"
|
ports: "{{ item.ports | default([]) | join(' ') }}"
|
||||||
stp: "{{ item.stp | default(omit) }}"
|
stp: "{{ item.stp | default(omit) }}"
|
||||||
vlan: "{{ item.vlan | default(omit) }}"
|
vlan: "{{ item.vlan | default(omit) }}"
|
||||||
igmp_snooping: "{{ item.igmp_snooping | default(omit) }}"
|
igmp_snooping: "{{ item.igmp_snooping | default(omit) }}"
|
||||||
ipv6: "{{ item.ipv6 | default(omit) }}"
|
ipv6: "{{ item.ipv6 | default(omit) }}"
|
||||||
|
replace: "yes"
|
||||||
@@ -4,22 +4,22 @@
|
|||||||
when: network_globals is defined
|
when: network_globals is defined
|
||||||
ansible.builtin.include_tasks: globals.yml
|
ansible.builtin.include_tasks: globals.yml
|
||||||
|
|
||||||
# Configure swconfig switch vlan section
|
# Configure swconfig vlan section
|
||||||
- name: Configure swconfig switch vlan section
|
- name: Configure swconfig vlan section
|
||||||
ansible.builtin.include_tasks: switch_swconfig.yml
|
ansible.builtin.include_tasks: swconfig.yml
|
||||||
when: network_swconfig_switch_vlans is defined
|
when: network_swconfig is defined
|
||||||
loop: "{{ network_swconfig_switch_vlans | default([]) }}"
|
loop: "{{ network_swconfig | default([]) }}"
|
||||||
|
|
||||||
# Configure dsa switch vlan section
|
|
||||||
- name: Configure dsa switch vlan section
|
|
||||||
ansible.builtin.include_tasks: switch_dsa.yml
|
|
||||||
when: network_dsa_switch_vlans is defined
|
|
||||||
loop: "{{ network_dsa_switch_vlans | default([]) }}"
|
|
||||||
|
|
||||||
# Configure device section
|
# Configure device section
|
||||||
- name: Configure device section
|
- name: Configure device section
|
||||||
ansible.builtin.include_tasks: device.yml
|
ansible.builtin.include_tasks: device.yml
|
||||||
loop: "{{ network_devices | default([]) }}"
|
loop: "{{ network_devices | default([]) + network_devices_append | default([]) }}"
|
||||||
|
|
||||||
|
# Configure dsa switch vlan section
|
||||||
|
- name: Configure dsa switch vlan section
|
||||||
|
ansible.builtin.include_tasks: vlan_filtering.yml
|
||||||
|
when: network_bridge_vlan_filtering is defined
|
||||||
|
loop: "{{ network_bridge_vlan_filtering | default([]) }}"
|
||||||
|
|
||||||
# Configure interface section
|
# Configure interface section
|
||||||
- name: Configure interface section
|
- name: Configure interface section
|
||||||
@@ -40,4 +40,16 @@
|
|||||||
- name: Apply changes and reload network
|
- name: Apply changes and reload network
|
||||||
uci:
|
uci:
|
||||||
command: commit
|
command: commit
|
||||||
notify: Reload network
|
|
||||||
|
# Reload network service
|
||||||
|
- name: Reload network
|
||||||
|
nohup:
|
||||||
|
command: /etc/init.d/network restart
|
||||||
|
# Update device ip address
|
||||||
|
- name: Update device ip address
|
||||||
|
set_fact:
|
||||||
|
ansible_host: "{{ device_ip_address }}"
|
||||||
|
when: device_ip_address is defined
|
||||||
|
- name: Wait target connection to become reachable/usable
|
||||||
|
ansible.builtin.wait_for_connection:
|
||||||
|
timeout: 30
|
||||||
31
roles/network/tasks/swconfig.yml
Normal file
31
roles/network/tasks/swconfig.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
# Set state status for switch vlan
|
||||||
|
- name: Set state status for switch vlan {{ item.vlan }}
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
switch_vlan_state: "{{ item.state | default('present') }}"
|
||||||
|
|
||||||
|
# Delete switch vlan
|
||||||
|
- name: Delete switch vlan {{ item.vlan }}
|
||||||
|
when: "'absent' in switch_vlan_state"
|
||||||
|
uci:
|
||||||
|
command: "absent"
|
||||||
|
config: "network"
|
||||||
|
type: "switch_vlan"
|
||||||
|
find:
|
||||||
|
vlan: "{{ item.vlan | mandatory }}"
|
||||||
|
|
||||||
|
# Create and configure switch vlan
|
||||||
|
- name: Create and configure switch vlan
|
||||||
|
when: "'present' in switch_vlan_state"
|
||||||
|
uci:
|
||||||
|
command: "section"
|
||||||
|
config: "network"
|
||||||
|
type: "switch_vlan"
|
||||||
|
find:
|
||||||
|
vlan: "{{ item.vlan | mandatory }}"
|
||||||
|
value:
|
||||||
|
device: "{{ item.device | default('switch0') }}"
|
||||||
|
vid: "{{ item.vid | default(item.vlan | default(omit)) }}"
|
||||||
|
ports: "{{ item.ports | default([]) }}"
|
||||||
|
description: "{{ item.description | default(omit) }}"
|
||||||
|
replace: "yes"
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
---
|
|
||||||
# Set state status for switch vlan
|
|
||||||
- name: Set state status for switch vlan {{ item.id | default('@switch_vlan[-1]') }}
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
switch_vlan_state: "{{ item.state | default('present') }}"
|
|
||||||
|
|
||||||
# Delete switch vlan
|
|
||||||
- name: Delete switch vlan {{ item.id }}
|
|
||||||
when: "'absent' in switch_vlan_state"
|
|
||||||
uci:
|
|
||||||
command: "absent"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id }}"
|
|
||||||
type: "switch_vlan"
|
|
||||||
|
|
||||||
# Create and configure switch vlan
|
|
||||||
- name: Create and configure switch vlan
|
|
||||||
when: "'present' in switch_vlan_state"
|
|
||||||
block:
|
|
||||||
# Create switch vlan
|
|
||||||
- name: Create switch vlan {{ item.id | default('@switch_vlan[-1]') }}
|
|
||||||
uci:
|
|
||||||
command: "add"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id | default('@switch_vlan[-1]') }}"
|
|
||||||
type: "switch_vlan"
|
|
||||||
|
|
||||||
# Configure switch vlan
|
|
||||||
- name: Configure switch vlan {{ item.id | default('@switch_vlan[-1]') }}
|
|
||||||
uci:
|
|
||||||
command: "set"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id | default('@switch_vlan[-1]') }}"
|
|
||||||
type: "switch_vlan"
|
|
||||||
value:
|
|
||||||
device: "{{ item.device | default('switch0') }}"
|
|
||||||
vlan: "{{ item.vlan | mandatory }}"
|
|
||||||
vid: "{{ item.vid | default(item.vlan | default(omit)) }}"
|
|
||||||
ports: "{{ item.ports | default([]) }}"
|
|
||||||
description: "{{ item.description | default(omit) }}"
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
---
|
|
||||||
# Set state status for switch vlan
|
|
||||||
- name: Set state status for switch vlan {{ item.id | default('@switch_vlan[-1]') }}
|
|
||||||
ansible.builtin.set_fact:
|
|
||||||
switch_vlan_state: "{{ item.state | default('present') }}"
|
|
||||||
|
|
||||||
# Delete switch vlan
|
|
||||||
- name: Delete switch vlan {{ item.id }}
|
|
||||||
when: "'absent' in switch_vlan_state"
|
|
||||||
uci:
|
|
||||||
command: "absent"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id }}"
|
|
||||||
type: "switch_vlan"
|
|
||||||
|
|
||||||
# Create and configure switch vlan
|
|
||||||
- name: Create and configure switch vlan
|
|
||||||
when: "'present' in switch_vlan_state"
|
|
||||||
block:
|
|
||||||
# Create switch vlan
|
|
||||||
- name: Create switch vlan {{ item.id | default('@switch_vlan[-1]') }}
|
|
||||||
uci:
|
|
||||||
command: "add"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id | default('@switch_vlan[-1]') }}"
|
|
||||||
type: "switch_vlan"
|
|
||||||
|
|
||||||
# Configure switch vlan
|
|
||||||
- name: Configure switch vlan {{ item.id | default('@switch_vlan[-1]') }}
|
|
||||||
uci:
|
|
||||||
command: "set"
|
|
||||||
config: "network"
|
|
||||||
section: "{{ item.id | default('@switch_vlan[-1]') }}"
|
|
||||||
type: "switch_vlan"
|
|
||||||
value:
|
|
||||||
device: "{{ item.device | default('switch0') }}"
|
|
||||||
vlan: "{{ item.vlan | mandatory }}"
|
|
||||||
vid: "{{ item.vid | default(item.vlan | default(omit)) }}"
|
|
||||||
ports: "{{ item.ports | default([]) }}"
|
|
||||||
description: "{{ item.description | default(omit) }}"
|
|
||||||
29
roles/network/tasks/vlan_filtering.yml
Normal file
29
roles/network/tasks/vlan_filtering.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
# Set state status for vlan filtering
|
||||||
|
- name: Set state status for switch vlan {{ item.vlan }}
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
switch_vlan_state: "{{ item.state | default('present') }}"
|
||||||
|
|
||||||
|
# Delete vlan filtering
|
||||||
|
- name: Delete switch vlan {{ item.vlan }}
|
||||||
|
when: "'absent' in switch_vlan_state"
|
||||||
|
uci:
|
||||||
|
command: "absent"
|
||||||
|
config: "network"
|
||||||
|
type: "bridge-vlan"
|
||||||
|
find:
|
||||||
|
vlan: "{{ item.vlan | mandatory }}"
|
||||||
|
|
||||||
|
# Create and configure vlan filtering
|
||||||
|
- name: Create and configure switch vlan
|
||||||
|
when: "'present' in switch_vlan_state"
|
||||||
|
uci:
|
||||||
|
command: "section"
|
||||||
|
config: "network"
|
||||||
|
type: "bridge-vlan"
|
||||||
|
find:
|
||||||
|
vlan: "{{ item.vlan | mandatory }}"
|
||||||
|
value:
|
||||||
|
device: "{{ item.device | mandatory }}"
|
||||||
|
ports: "{{ item.ports | default([]) }}"
|
||||||
|
replace: "yes"
|
||||||
@@ -18,6 +18,10 @@
|
|||||||
opkg:
|
opkg:
|
||||||
name: prometheus-node-exporter-lua
|
name: prometheus-node-exporter-lua
|
||||||
state: present
|
state: present
|
||||||
|
- name: Install prometheus-node-exporter-lua-hostapd_stations
|
||||||
|
opkg:
|
||||||
|
name: prometheus-node-exporter-lua-hostapd_stations
|
||||||
|
state: present
|
||||||
- name: Configure prometheus-node-exporter-lua
|
- name: Configure prometheus-node-exporter-lua
|
||||||
uci:
|
uci:
|
||||||
command: section
|
command: section
|
||||||
@@ -28,7 +32,7 @@
|
|||||||
listen_interface: mgmnt
|
listen_interface: mgmnt
|
||||||
listen_port: 9100
|
listen_port: 9100
|
||||||
autocommit: true
|
autocommit: true
|
||||||
# - name: Reboot device
|
- name: Reboot device
|
||||||
# ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
# cmd: "reboot"
|
cmd: "reboot"
|
||||||
# changed_when: false
|
changed_when: false
|
||||||
|
|||||||
Reference in New Issue
Block a user