The --yes is needed because installation prompts a yes/no question.
I can’t figure out how to accomplish this same task through Ansible. It seems that ansible’s apt allows the inclusions of dpkg_options, but those options are apparently different from apt’s options, and there is no ‘–yes’ option in dpkg.
Does manual installation from the shell work? Because, this error:
Dependency is not satisfiable: libglib2.0-0 (>= 2.37.3)
indicate something entirely different (bad dependency) instead of prompt not being answered. When prompt is not answered, it usually hangs.
On the other hand, the prompt displayed is most likely not from the apt or dpkg but from the pre install script inside a package (EULA acceptance?). That’s why --yes has no effect. I have seen this in some Microsoft packages, not sure about VS Code.
The good thing about Microsoft packages is that you can define environment variable to automatically accept EULA (unattended install) which can be done in Ansible like so: