Rozdělení do skupin DSA a swconfig, úprava role network

This commit is contained in:
2024-11-01 03:32:26 +01:00
parent 587ca23374
commit cde297bd2e
18 changed files with 201 additions and 268 deletions

View File

@@ -1,42 +1,33 @@
---
# 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:
network_device_state: "{{ item.state | default('present') }}"
# Delete network device
- name: Delete network device {{ item.id }}
- name: Delete network device {{ item.name }}
when: "'absent' in network_device_state"
uci:
command: "absent"
config: "network"
section: "{{ item.id }}"
type: "device"
find:
name: "{{ item.name | mandatory }}"
# Create and configure network device
- name: Create and configure network device
when: "'present' in network_device_state"
block:
# Create network device
- name: Create network device {{ item.id | default('@device[-1]') }}
uci:
command: "add"
config: "network"
section: "{{ item.id | default('@device[-1]') }}"
type: "device"
# 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) }}"
type: "{{ item.type | default(omit) }}"
ports: "{{ item.ports | default([]) | join(' ') }}"
stp: "{{ item.stp | default(omit) }}"
vlan: "{{ item.vlan | default(omit) }}"
igmp_snooping: "{{ item.igmp_snooping | default(omit) }}"
ipv6: "{{ item.ipv6 | default(omit) }}"
uci:
command: "section"
config: "network"
type: "device"
find:
name: "{{ item.name | default(omit) }}"
value:
type: "{{ item.type | default(omit) }}"
ports: "{{ item.ports | default([]) | join(' ') }}"
stp: "{{ item.stp | default(omit) }}"
vlan: "{{ item.vlan | default(omit) }}"
igmp_snooping: "{{ item.igmp_snooping | default(omit) }}"
ipv6: "{{ item.ipv6 | default(omit) }}"
replace: "yes"