summaryrefslogtreecommitdiffstats
path: root/roles/network
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-07-06 01:49:45 +0200
committerAhmed Abdelhalim <[email protected]>2026-07-06 01:49:45 +0200
commit09fbb2b1d86b8ad6671c746f3df997390f7a6293 (patch)
tree24cddc6e7b0ad6c18a320d215e67b9c6970ef246 /roles/network
parent0e7e66f00da0b37ef68cca0d13a1588a30cb9235 (diff)
Fix pve network setup
Diffstat (limited to 'roles/network')
-rw-r--r--roles/network/meta/argument_specs.yml4
-rw-r--r--roles/network/tasks/main.yml9
-rw-r--r--roles/network/templates/bridge.nmconnection.j229
-rw-r--r--roles/network/templates/eth0-connection.nmconnection.j212
4 files changed, 52 insertions, 2 deletions
diff --git a/roles/network/meta/argument_specs.yml b/roles/network/meta/argument_specs.yml
index 86df33c6..f85318a8 100644
--- a/roles/network/meta/argument_specs.yml
+++ b/roles/network/meta/argument_specs.yml
@@ -30,3 +30,7 @@ argument_specs:
network_ipv6_dns:
type: "str"
description: "The network IP(4) gateway to configure when provided"
+ network_bridge:
+ type: "str"
+ description: "Bridge interface name — when set, ethernet becomes bridge port and bridge connection is created"
+ required: false
diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml
index 2cbb2513..1268b3cd 100644
--- a/roles/network/tasks/main.yml
+++ b/roles/network/tasks/main.yml
@@ -103,6 +103,15 @@
owner: "root"
group: "root"
+ - name: "Configure bridge connection"
+ ansible.builtin.template:
+ src: "bridge.nmconnection.j2"
+ dest: "/etc/NetworkManager/system-connections/{{ network_bridge }}.nmconnection"
+ mode: "0600"
+ owner: "root"
+ group: "root"
+ when: network_bridge is defined
+
- name: "Configure wifi connection"
ansible.builtin.template:
src: "wifi-connection.nmconnection.j2"
diff --git a/roles/network/templates/bridge.nmconnection.j2 b/roles/network/templates/bridge.nmconnection.j2
new file mode 100644
index 00000000..2e8bf23c
--- /dev/null
+++ b/roles/network/templates/bridge.nmconnection.j2
@@ -0,0 +1,29 @@
+[connection]
+id={{ network_bridge }}
+type=bridge
+interface-name={{ network_bridge }}
+autoconnect=true
+
+[bridge]
+stp=false
+
+[ipv4]
+method=manual
+addresses={{ network_ipv4_address }}/{{ network_ipv4_prefix | default(24) }}
+gateway={{ network_ipv4_gateway }}
+{% if network_ipv4_dns is defined %}
+dns={{ network_ipv4_dns }}
+{% endif %}
+
+[ipv6]
+addr-gen-mode=default
+{% if network_ipv6_address is defined %}
+method=manual
+addresses={{ network_ipv6_address }}
+gateway={{ network_ipv6_gateway }}
+{% if network_ipv6_dns is defined %}
+dns={{ network_ipv6_dns }}
+{% endif %}
+{% else %}
+method=disabled
+{% endif %}
diff --git a/roles/network/templates/eth0-connection.nmconnection.j2 b/roles/network/templates/eth0-connection.nmconnection.j2
index 666b0360..6a6481c4 100644
--- a/roles/network/templates/eth0-connection.nmconnection.j2
+++ b/roles/network/templates/eth0-connection.nmconnection.j2
@@ -2,12 +2,18 @@
id=ethernet
type=ethernet
autoconnect=true
+{% if network_bridge is defined %}
+controller={{ network_bridge }}
+port-type=bridge
+{% endif %}
[ethernet]
cloned-mac-address=permanent
[ipv4]
-{% if network_ipv4_address is defined %}
+{% if network_bridge is defined %}
+method=disabled
+{% elif network_ipv4_address is defined %}
method=manual
addresses={{ network_ipv4_address }}
gateway={{ network_ipv4_gateway }}
@@ -20,7 +26,9 @@ method=auto
[ipv6]
addr-gen-mode=default
-{% if network_ipv6_address is defined %}
+{% if network_bridge is defined %}
+method=disabled
+{% elif network_ipv6_address is defined %}
method=manual
addresses={{ network_ipv6_address }}
gateway={{ network_ipv6_gateway }}