In order to disable the GUI on Ubuntu 20.04 with Ansible, you can use this task:

    - name: Disable GUI (Change default target to graphical.target)
      file:
        src: /usr/lib/systemd/system/multi-user.target
        dest: /etc/systemd/system/default.target
        state: link
      become: true