1

It looks like like command apt install https://github.com/jgraph/drawio-desktop/releases/download/v12.9.3/draw.io-amd64-12.9.3.deb could take long time each time when is invoked even if the package is installed already. It is literally downloads the package each time.

And yes, with ansible is idempotent, with status changed: no.

- name: Install a drawio-desktop .deb package
  apt:
    deb: https://github.com/jgraph/drawio-desktop/releases/download/v12.9.3/draw.io-amd64-12.9.3.deb
  when: ansible_facts['lsb']['id'] == "Ubuntu"
  tags:
    - debug
    - not-macos

Is there any short way to skip download if package installed ?

Ideally will be to say in name that I want to install draw.io if not installed from deb: url else consider things installed.

- name: Install a drawio-desktop .deb package
  apt:
    name: draw.io
    deb: https://github.com/jgraph/drawio-desktop/releases/download/v12.9.3/draw.io-amd64-12.9.3.deb

but is not working like that

TASK [desktop : Install a drawio-desktop .deb package] *********
fatal: [tuxedo]: FAILED! => {"changed": false, "msg": "parameters are mutually exclusive: deb|package|upgrade"}

Any suggestion on a lighter solution to speed up the task?

U880D
  • 8,601
  • 6
  • 24
  • 40
Andrei.Danciuc
  • 1,000
  • 10
  • 24

1 Answers1

1

The behavior seems to be intended according the parameter deb

Ansible will attempt to download deb before installing.

and the current source of apt.py.

So you may have a look into the module package_facts

- name: Gather Package Facts
  package_facts:
    manager: apt # default ["auto"]

as well a Conditional Example of

  when: "ansible_facts['lsb']['id'] == 'Ubuntu' and 'draw.io' not in ansible_facts.packages"

Credits to

Further Q&A


An other approach might be to have the latest package always internally (cached) available and provide a .list file for the native package manager, pointing to the internal repository URL (file share).

By doing this, you could then just use

- name: Install a drawio-desktop .deb package
  apt:
    name: draw.io
    state: latest

without further checks. This will address required updates too.

U880D
  • 8,601
  • 6
  • 24
  • 40