community.general.snap – Manages snaps

Note

This plugin is part of the community.general collection (version 3.8.3).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.snap.

Synopsis

  • Manages snaps packages.

Parameters

Parameter

Comments

channel

string

Define which release of a snap is installed and tracked for updates. This option can only be specified if there is a single snap in the task.

Default: “stable”

classic

boolean

Confinement policy. The classic confinement allows a snap to have the same level of access to the system as “classic” packages, like those managed by APT. This option corresponds to the –classic argument. This option can only be specified if there is a single snap in the task.

Choices:

  • no ← (default)

  • yes

name

list / elements=string / required

Name of the snaps.

state

string

Desired state of the package.

Choices:

  • absent

  • present ← (default)

  • enabled

  • disabled

Examples

# Install "foo" and "bar" snap
- name: Install foo
  community.general.snap:
    name:
      - foo
      - bar

# Remove "foo" snap
- name: Remove foo
  community.general.snap:
    name: foo
    state: absent

# Install a snap with classic confinement
- name: Install "foo" with option --classic
  community.general.snap:
    name: foo
    classic: yes

# Install a snap with from a specific channel
- name: Install "foo" with option --channel=latest/edge
  community.general.snap:
    name: foo
    channel: latest/edge

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

channel

string

The channel the snaps were installed from

Returned: When snaps are installed

classic

boolean

Whether or not the snaps were installed with the classic confinement

Returned: When snaps are installed

cmd

string

The command that was executed on the host

Returned: When changed is true

snaps_installed

list / elements=string

The list of actually installed snaps

Returned: When any snaps have been installed

snaps_removed

list / elements=string

The list of actually removed snaps

Returned: When any snaps have been removed

Authors