community.general.snap_connect module – Manages snap interface connections

Note

This module is part of the community.general collection (version 13.0.1).

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_connect.

New in community.general 12.6.0

Synopsis

  • Manages connections between snap plugs and slots.

  • Snaps run in a sandbox and need explicit interface connections to access system resources or communicate with other snaps.

Parameters

Parameter

Comments

plug

string / required

The plug endpoint in the format <snap>:<plug>.

slot

string

The slot endpoint in the format <snap>:<slot> or :<slot> for system slots.

If not specified, snapd will attempt to find a matching slot automatically.

state

string

Desired state of the connection.

Choices:

  • "absent"

  • "present" ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: full

Returns details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

  • Privileged operations require root privileges.

See Also

See also

community.general.snap

Manages snaps.

community.general.snap_alias

Manages snap aliases.

Examples

- name: Connect firefox camera plug to system camera slot
  community.general.snap_connect:
    plug: firefox:camera
    slot: ":camera"

- name: Connect snap plug (slot resolved automatically by snapd)
  community.general.snap_connect:
    plug: my-app:network

- name: Disconnect a specific connection
  community.general.snap_connect:
    plug: firefox:camera
    slot: ":camera"
    state: absent

Return Values

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

Key

Description

snap_connections

list / elements=dictionary

The list of snap connections after execution.

Returned: always

interface

string

The interface name.

Returned: success

plug

string

The plug endpoint.

Returned: success

slot

string

The slot endpoint.

Returned: success

version

dictionary

Versions of snap components as reported by snap version.

Returned: always

Authors

  • Alexei Znamensky (@russoz)