diff --git a/inventories/netplan_cluster_example.yaml.j2 b/inventories/netplan_cluster_example.yaml.j2 deleted file mode 100644 index cc47f63b8..000000000 --- a/inventories/netplan_cluster_example.yaml.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2024 Savoir-faire Linux, Inc. -# SPDX-License-Identifier: Apache-2.0 -# This netplan files defines the path of the cluster network which is managed -# by systemd. Especially, it attributes its cluster IP addr to each node. -network: - version: 2 - renderer: networkd - ethernets: - "{{ team0_0|default('0') }}": - mtu: 9000 - dhcp4: no - dhcp6: no - optional: true - "{{ team0_1|default('0') }}": - mtu: 9000 - dhcp4: no - dhcp6: no - optional: true - bridges: - team0: - interfaces: - - "{{ team0_0|default('0') }}" - - "{{ team0_1|default('0') }}" - addresses: - - "{{ cluster_ip_addr|default('0') }}/{{ subnet|default(24) }}" - openvswitch: - rstp: true - other-config: - rstp-priority: "{{ br_rstp_priority }}" - parameters: - stp: false - forward-delay: 4 - mtu: 9000 - dhcp4: no - dhcp6: no diff --git a/inventories/seapath_cluster_definition_example.yml b/inventories/seapath_cluster_definition_example.yml index d3f9c32d7..5b87c1ff6 100644 --- a/inventories/seapath_cluster_definition_example.yml +++ b/inventories/seapath_cluster_definition_example.yml @@ -15,7 +15,6 @@ all: netplan_configurations : - inventories/netplan_admin_br0_example.yaml.j2 - inventories/netplan_ptp_interface_example.yaml.j2 - - inventories/netplan_cluster_example.yaml.j2 # Main network configuration network_interface: eno8303 #admin interface @@ -60,7 +59,6 @@ all: netplan_configurations : - inventories/netplan_admin_br0_example.yaml.j2 - inventories/netplan_ptp_interface_example.yaml.j2 - - inventories/netplan_cluster_example.yaml.j2 # Main network configuration network_interface: eno8303 @@ -96,10 +94,9 @@ all: ansible_host: 10.10.10.3 hostname: "node3" - netplan_configurations : + netplan_configurations: - inventories/netplan_admin_br0_example.yaml.j2 - inventories/netplan_ptp_interface_example.yaml.j2 - - inventories/netplan_cluster_example.yaml.j2 # Main network interface configuration network_interface: eno8303 diff --git a/playbooks/seapath_setup_network.yaml b/playbooks/seapath_setup_network.yaml index 5874b6bd1..773ae2d68 100644 --- a/playbooks/seapath_setup_network.yaml +++ b/playbooks/seapath_setup_network.yaml @@ -12,7 +12,11 @@ become: true gather_facts: true vars_files: - - ../vars/network_vars.yml + - "../vars/network_team0.yml" + pre_tasks: + - name: Dynamically include network configuration variables + include_vars: + file: "../vars/network_{{ 'empty' if netplan_configurations is defined or (network_simple is defined and network_simple) else 'defaults' }}.yml" roles: - role: network_basics - role: systemd_networkd diff --git a/roles/network_clusternetwork/tasks/main.yml b/roles/network_clusternetwork/tasks/main.yml index 22cf39fc5..fdd8d9b42 100644 --- a/roles/network_clusternetwork/tasks/main.yml +++ b/roles/network_clusternetwork/tasks/main.yml @@ -32,7 +32,6 @@ when: - cluster_protocol is not defined or cluster_protocol != "HSR" or hsr_mac_address is not defined - skip_recreate_team0_config is not defined or skip_recreate_team0_config is not true - - netplan_configurations is not defined - block: - name: copy hsr.sh script template: @@ -71,4 +70,3 @@ state: restarted when: hsr1.changed or hsr2.changed or hsr3.changed or hsrservice.changed when: cluster_protocol is defined and cluster_protocol == "HSR" and hsr_mac_address is defined - diff --git a/vars/network_vars.yml b/vars/network_defaults.yml similarity index 80% rename from vars/network_vars.yml rename to vars/network_defaults.yml index f3c677116..d59199d1d 100644 --- a/vars/network_vars.yml +++ b/vars/network_defaults.yml @@ -1,9 +1,10 @@ # Copyright (C) 2021, RTE (http://www.rte-france.com) +# Copyright (C) 2024 Savoir-faire Linux, Inc. # SPDX-License-Identifier: Apache-2.0 --- -systemd_networkd_network_custom: "{{ custom_network | default([]) }}" -systemd_networkd_netdev_custom: "{{ custom_netdev | default([]) }}" +systemd_networkd_network_custom: "{{ custom_network | default({}) }}" +systemd_networkd_netdev_custom: "{{ custom_netdev | default({}) }}" br0vlan_systemd_networkd_netdev: 79-br0: @@ -64,22 +65,5 @@ wired_systemd_networkd_network: "{{ br0vlan_systemd_networkd_network if br0vlan systemd_networkd_netdev_nocluster: "{{ wired_systemd_networkd_netdev | combine(systemd_networkd_netdev_custom) }}" systemd_networkd_network_nocluster: "{{ wired_systemd_networkd_network | combine(systemd_networkd_network_custom) }}" -team0_systemd_networkd_network: - 79-team0: - - Match: - - Name: "team0" - - Network: - - Address: "{{ cluster_ip_addr|default('0') }}/{{ team0subnet | default(24) }}" - 79-team0_0: - - Match: - - Name: "{{ team0_0|default('0') }}" - - Link: - - MTUBytes: 1800 - 79-team0_1: - - Match: - - Name: "{{ team0_1|default('0') }}" - - Link: - - MTUBytes: 1800 - systemd_networkd_network: "{{ systemd_networkd_network_nocluster|combine(team0_systemd_networkd_network) if cluster_ip_addr is defined else systemd_networkd_network_nocluster}}" systemd_networkd_netdev: "{{ systemd_networkd_netdev_nocluster }}" diff --git a/vars/network_empty.yml b/vars/network_empty.yml new file mode 100644 index 000000000..21359678c --- /dev/null +++ b/vars/network_empty.yml @@ -0,0 +1,11 @@ +# Copyright (C) 2021, RTE (http://www.rte-france.com) +# Copyright (C) 2024 Savoir-faire Linux, Inc. +# SPDX-License-Identifier: Apache-2.0 +--- + +systemd_networkd_network_custom: "{{ custom_network | default({}) }}" +systemd_networkd_netdev: "{{ custom_netdev | default({}) }}" + +systemd_networkd_network: "{{ team0_systemd_networkd_network | combine(systemd_networkd_network_custom) if cluster_ip_addr is defined else systemd_networkd_network_custom }}" + +... diff --git a/vars/network_team0.yml b/vars/network_team0.yml new file mode 100644 index 000000000..00bec24c9 --- /dev/null +++ b/vars/network_team0.yml @@ -0,0 +1,24 @@ +# Copyright (C) 2021-2024, RTE (http://www.rte-france.com) +# Copyright (C) 2024 Savoir-faire Linux, Inc. +# SPDX-License-Identifier: Apache-2.0 + +--- + +team0_systemd_networkd_network: + 79-team0: + - Match: + - Name: "team0" + - Network: + - Address: "{{ cluster_ip_addr|default('0') }}/{{ team0subnet | default(24) }}" + 79-team0_0: + - Match: + - Name: "{{ team0_0|default('0') }}" + - Link: + - MTUBytes: 1800 + 79-team0_1: + - Match: + - Name: "{{ team0_1|default('0') }}" + - Link: + - MTUBytes: 1800 + +...