Ansible – How to Upgrade Snap Packages

ansiblen3drsnap

The aim is to upgrade snap packages, e.g. n3dr and informado, using Ansible. The following task has been created:

- name: Install various snap packages
  snap:
    name:
      - informado
      - n3dr

Attempts to solve the issue

The following websites were consulted:

There seems to be no option to upgrade snap package using ansible

A GitHub issue has been created.

Workaround

  1. remove the to be updated packages

     user@host:~$ sudo snap remove informado n3dr
     2020-07-15T10:21:18+02:00 INFO Waiting for
     conflicting change in progress...
     informado removed
     n3dr removed
    
  2. run ansible again

  3. the newest version of the n3dr and informado have been installed

Question

How to upgrade snap packages without removing them first, using ansible?

Best Answer

I guess this functionality hasn't been implemented in the module because:

Updates are automatically installed within 6 hours of a revision being made to a tracked channel, keeping most systems up-to-date. This schedule can be tuned via configuration options.

snapcraft.io Getting Started

It should be possible to update a single package using the command module:

- name: Update snap package
  command: snap refresh package_name