Apt deb --yes option

I want to install vscode from a deb file on all of our machines. Installing manually looks like this:

apt install --yes ./code_1.93.1-1726079302_amd64.deb

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.

- name: VSCode
      apt:
        deb: './code_1.93.1-1726079302_amd64.deb'
        dpkg_options: "yes"

This playbook returns:

TASK [VSCode] ***************************************************************************************************************************************************
fatal: [10.0.0.64]: FAILED! => {"changed": false, "msg": "Dependency is not satisfiable: libglib2.0-0 (>= 2.37.3)\n"}

I appreciate the help.

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:

- name: "VSCode"
  apt:
    deb: './code_1.93.1-1726079302_amd64.deb'
  environment:
    ACCEPT_EULA: "y"

It is possible that for VS Code the environment variable has different name so please consult with the VS Code documentation.

3 Likes