Configure Wifi on Ubuntu Server with Netplan

Add a file, 1-wlan0.yaml, to /etc/netplan/ with the following contents,

$ sudo cat << EOF >> /etc/netplan/1-wlan0.yaml
network:
    version: 2
    wifis:
        wlan0:
            optional: true
            access-points:
                NAME_OF_YOUR_ESSID:
                    password: "YOUR_SECRET_WPA_PSK_HERE"
            dhcp4: true
            dhcp6: true
EOF

Then apply the plan,

$ sudo netplan apply