Rocky9 automatic connect to wifi and static ip

Hello,

As using dhcp is not an option for me and i pushed my ideas a bit further and found a solution.
I noticed, that with Ubuntu server i dont have this network problem. Ubuntu uses netplan and systemd-networkd as renderer. So here it is what i did with Rocky9.

  1. Disabled wifi device management within NetworkManager:
# cat /etc/NetworkManager/conf.d/100-unmanaged.conf 
[keyfile]
unmanaged-devices=type:wifi
  1. Installed “netplan-default-backend-networkd” package (epel repo), created a new configuration for usb wifi dongle like that:
#
network:
  version: 2
  renderer: networkd
  ethernets:
    wlp1s0f0u4:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.1.129/24]
      nameservers:
        addresses: [192.168.1.1, 1.1.1.1]
      routes:
        - to: default
          via: 192.168.1.1
  1. New wpa_supplicant.service (Note: this bugged me as hell, below is what finally works, Note2: keep an eye on selinux!):
[Unit]
Description=WPA supplicant
After=network-online.target
Wants=network.target
IgnoreOnIsolate=true

[Service]
Type=Simple
RemainAfterExit=yes
ExecStart=/usr/sbin/wpa_supplicant -s -c /etc/wpa_supplicant/wpa_supplicant.conf -D nl80211,wext -i wlp1s0f0u4
Restart=always
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
Alias=dbus-fi.w1.wpa_supplicant1.service
  1. wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel
update_config=1
country=US
network={
        ssid="xxx"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="sec"
        }
network={
        ssid="yyy"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="sec"
        }
network={
        ssid="zzz"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="sec"
        }

I wish i could do it without netplan/networkd, but this is the situation i can live with at least for now.