From a2340a900f6a2b71666e9fad2b290debda7c86aa Mon Sep 17 00:00:00 2001 From: jonas Date: Tue, 23 Nov 2021 13:11:36 +0100 Subject: [PATCH] break out br0 from hostapd --- salt/states/br0/init.sls | 14 ++++++++++++++ salt/states/hostapd/init.sls | 17 ----------------- salt/states/top.sls | 1 + 3 files changed, 15 insertions(+), 17 deletions(-) create mode 100644 salt/states/br0/init.sls diff --git a/salt/states/br0/init.sls b/salt/states/br0/init.sls new file mode 100644 index 0000000..d510ec8 --- /dev/null +++ b/salt/states/br0/init.sls @@ -0,0 +1,14 @@ +Set {{ pillar['network']['bridge'] }} to be managed by NetworkManager: + cmd.run: + - name: nmcli device set {{ pillar['network']['bridge'] }} managed yes + - unless: bash -c "if [[ \"$(nmcli device show {{ pillar['network']['bridge'] }} | sed -n 's/^GENERAL.STATE.*(\(.*\)).*$/\1/p')\" == \"unmanaged\" ]]; then exit 1; else exit 0; fi" + +Configure {{ pillar['network']['bridge'] }} connection: + cmd.run: + - name: nmcli connection add con-name {{ pillar['network']['bridge'] }} type bridge ifname {{ pillar['network']['bridge'] }} ipv4.method manual ipv4.addresses {{ pillar['network']['ip'] }}/24 ipv4.dns "127.0.0.1, 1.1.1.1, 1.1.1.2" ipv6.method disabled connection.autoconnect yes stp no + - unless: nmcli connection show {{ pillar['network']['bridge'] }} > /dev/null + +Add {{ pillar['network']['interface'] }} to bridge {{ pillar['network']['bridge'] }}: + cmd.run: + - name: nmcli connection add con-name {{ pillar['network']['bridge'] }}-{{ pillar['network']['interface'] }} ifname {{ pillar['network']['interface'] }} type bridge-slave master {{ pillar['network']['bridge'] }} connection.autoconnect yes + - unless: nmcli connection show {{ pillar['network']['bridge'] }}-{{ pillar['network']['interface'] }} > /dev/null diff --git a/salt/states/hostapd/init.sls b/salt/states/hostapd/init.sls index edabace..4a70ed9 100644 --- a/salt/states/hostapd/init.sls +++ b/salt/states/hostapd/init.sls @@ -49,20 +49,3 @@ Start hostapd: - enable: True - watch: - file: Configure hostapd - -Set {{ pillar['network']['bridge'] }} to be managed by NetworkManager: - cmd.run: - - name: nmcli device set {{ pillar['network']['bridge'] }} managed yes - - unless: bash -c "if [[ \"$(nmcli device show {{ pillar['network']['bridge'] }} | sed -n 's/^GENERAL.STATE.*(\(.*\)).*$/\1/p')\" == \"unmanaged\" ]]; then exit 1; else exit 0; fi" - -Configure {{ pillar['network']['bridge'] }} connection: - cmd.run: - - name: nmcli connection add con-name {{ pillar['network']['bridge'] }} type bridge ifname {{ pillar['network']['bridge'] }} ipv4.method manual ipv4.addresses {{ pillar['network']['ip'] }}/24 ipv4.dns "127.0.0.1, 1.1.1.1, 1.1.1.2" ipv6.method disabled connection.autoconnect yes stp no - - unless: nmcli connection show {{ pillar['network']['bridge'] }} > /dev/null - -Add {{ pillar['network']['interface'] }} to bridge {{ pillar['network']['bridge'] }}: - cmd.run: - - name: nmcli connection add con-name {{ pillar['network']['bridge'] }}-{{ pillar['network']['interface'] }} ifname {{ pillar['network']['interface'] }} type bridge-slave master {{ pillar['network']['bridge'] }} connection.autoconnect yes - - unless: nmcli connection show {{ pillar['network']['bridge'] }}-{{ pillar['network']['interface'] }} > /dev/null - - diff --git a/salt/states/top.sls b/salt/states/top.sls index 235b228..aeadd00 100644 --- a/salt/states/top.sls +++ b/salt/states/top.sls @@ -2,6 +2,7 @@ base: '*': - packages - hosts + - br0 - vlan - hostapd - firewalld