GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Failed to query AppArmor policy: Permission denied tasksel: apt-get failed (100)

You are trying to use tasksel, which is this one, https://wiki.debian.org/tasksel

The GDbus is about D-Bus, which is normally present on desktop environments.
tasksel appears to require it when it tries to install the desktop package selection.
But, if you do not need such a selection, it should work.
Isn’t tasksel supposed to work as well on Linux servers without any GUI component?