snap
¶
Interface with the Snapd REST API and the snap
CLI.
- class saltext.snap.modules.snap_mod.APIConnectionError(*args: Any, **kwargs: Any)[source]¶
Unifies http.client.HTTPException and requests.RequestException for error handling in callers.
- saltext.snap.modules.snap_mod.ack(path)[source]¶
Check and import assertions from a file.
CLI Example:
salt '*' snap.ack $(pwd)/hello-world_29.assert
- path
The path to the assertions file.
- saltext.snap.modules.snap_mod.api(endpoint, method='get', **query)[source]¶
Query the Snapd REST API directly.
CLI Example:
salt '*' snap.api connections select=all
- endpoint
The API endpoint, without
/v2/
prefix.- method
The API method to use. Defaults to
get
.
Query parameters can be passed as supplemental keyword arguments.
- saltext.snap.modules.snap_mod.connect(name, connector, target=None, wait=True)[source]¶
Connect a plug to a slot.
CLI Example:
salt '*' snap.connect bitwarden password-manager-service
- name
The name of the snap to connect.
- connector
The name of the snap’s plug to connect.
- target
A specification for the slot to connect to. Optional. Full spec:
<snap_name>:<slot_name>
. If left unspecified, connects the plug to a slot of the core snap with a name matchingplug
. If specified as a snap name only, connects the plug to the only slot in the provided snap that matches the connection interface, but fails if multiple potential slots exist.- wait
Wait for the operation to complete. Defaults to true.
- saltext.snap.modules.snap_mod.connections(name=None, interface=None, all=False)[source]¶
List interface connection information.
CLI Example:
salt '*' snap.connections salt '*' snap.connections bw salt '*' snap.connections interface=network-bind
- name
Only show connections involving this single snap. Optional. When this is specified, only connected plugs and slots are returned, regardless of
all
. This is an API limitation.- interface
Only show connections involving this interface. Optional.
- all
When
name
is unspecified, include unconnected plugs/slots in the output. When a name is specified, this is done automatically. Defaults to false.
- saltext.snap.modules.snap_mod.plugs(name, plug=None, interface=None, connected=None)[source]¶
List plugs a snap exposes.
CLI Example:
salt '*' snap.plugs bitwarden
- name
The name of the snap.
- plug
Only return information about a plug with this name. Optional.
- interface
Only return information about a plug with this interface. Optional.
- connected
Filter by connection status. Optional. Set this to true to only show connected plugs, set this to false to only show unconnected ones.
- saltext.snap.modules.snap_mod.slots(name, slot=None, interface=None, connected=None)[source]¶
List slots a snap exposes.
CLI Example:
salt '*' snap.slots core
- name
The name of the snap.
- slot
Only return information about a slot with this name. Optional.
- interface
Only return information about a slot with this interface. Optional.
- connected
Filter by connection status. Optional. Set this to true to only show connected slots, set this to false to only show unconnected ones.
- saltext.snap.modules.snap_mod.disconnect(name, connector, target=None, forget=False, wait=True)[source]¶
Disconnect a plug’s/slot’s connections.
CLI Example:
salt '*' snap.disconnect bitwarden password-manager-service
- name
The name of the snap to disconnect. The
core
snap must be spelled out as well.- connector
The name of the snap’s plug/slot to disconnect.
- target
A specification for the slot/plug to disconnect from in the format <snap_name>:<slot_or_plug_name>`. Optional. If left unspecified, disconnects all connections of the plug/slot.
- forget
When an automatic connection has been disconnected manually, its state will be remembered, even after a snap refresh. Set this to true to reset the connection’s state, thus making it autoconnect again after a snap refresh. Defaults to false.
- wait
Wait for the operation to complete. Defaults to true.
- saltext.snap.modules.snap_mod.disable(name)[source]¶
Disable a snap.
CLI Example:
salt '*' snap.disable hello-world
- name
The name of the snap.
- saltext.snap.modules.snap_mod.enable(name)[source]¶
Enable a snap.
CLI Example:
salt '*' snap.enable hello-world
- name
The name of the snap.
- saltext.snap.modules.snap_mod.hold(name, duration=None)[source]¶
Exclude a snap from general refreshes.
CLI Example:
salt '*' snap.hold hello-world
- name
The name of the snap.
- duration
Optional duration to hold for, specified as a time string with a unit. If unspecified, holds forever until the snap is manually unheld.
- saltext.snap.modules.snap_mod.unhold(name)[source]¶
Remove a hold on a snap.
CLI Example:
salt '*' snap.unhold hello-world
- name
The name of the snap.
- saltext.snap.modules.snap_mod.info(name, verbose=False)[source]¶
Show information about a snap. It does not have to be installed.
CLI Example:
salt '*' snap.info hello-world salt '*' snap.info '[hello-world, core]'
- name
The name(s) of the snap(s).
- verbose
Include more details on the snap.
- saltext.snap.modules.snap_mod.interfaces(name=None, all=False)[source]¶
Query interface types.
CLI Example:
salt '*' snap.interfaces salt '*' snap.interfaces network salt '*' snap.interfaces '[network, network-bind]' salt '*' snap.interfaces x11 all=true
- name
Filter by interface name(s). Optional.
- all
By default, this only lists interfaces with active connections. Set this to true to also list those without.
- saltext.snap.modules.snap_mod.install(name, channel=None, revision=None, classic=False, refresh=False)[source]¶
Install a snap.
CLI Example:
salt '*' snap.install hello-world
- name
The name of the snap or a path to a local file. If you’re passing the path to a downloaded snap, ensure you have imported the accompanying assertions before using
snap.ack
. The other parameters are irrelevant in that case.- channel
Follow this channel instead of stable.
- revision
Install this revision instead of the latest one available in the channel.
- classic
Enable classic mode and disable security confinement. Defaults to false.
- refresh
Update an already installed snap instead of installing a new one. This can also be used to modify installation parameters like the channel. Defaults to false.
- saltext.snap.modules.snap_mod.is_enabled(name)[source]¶
Check whether a snap is enabled.
CLI Example:
salt '*' snap.is_enabled hello-world
- name
The name of the snap.
- saltext.snap.modules.snap_mod.is_held(name)[source]¶
Check whether a snap is held.
CLI Example:
salt '*' snap.is_held hello-world
- name
The name of the snap.
- saltext.snap.modules.snap_mod.is_installed(name)[source]¶
Check whether a snap is installed.
CLI Example:
salt '*' snap.is_installed hello-world
- name
The name of the snap.
- saltext.snap.modules.snap_mod.is_uptodate(name=None, exclude_held=False)[source]¶
Check whether a snap/all installed snaps are up to date.
CLI Example:
salt '*' snap.is_uptodate salt '*' snap.is_uptodate hello-world
- name
The name of the snap. Optional. If missing, will check all snaps.
- exclude_held
Count held snaps as up to date. Defaults to False.
- saltext.snap.modules.snap_mod.known(assert_type, **kwargs)[source]¶
List known assertions.
CLI Example:
salt '*' snap.known snap-revision snap-sha3-384=sHvbeOdiwuYCDHX6_JIFWzI6b42jq0Kjlj2lreOGq6Efd-PI-Rm4qiPzqlwGyET5
- assert_type
The type of assertion to list.
- kwargs
Filter returned assertions by header values, passed as supplemental keyword arguments.
- saltext.snap.modules.snap_mod.list_(name=None, revisions=False, verbose=False)[source]¶
List all installed snaps.
CLI Example:
salt '*' snap.list salt '*' snap.list hello-world salt '*' snap.list '[hello-world, core]'
- name
Filter for the name(s) of specified snap(s). Optional.
- revisions
List all revisions. Defaults to false.
- verbose
List more detailed information. This requires being able to query the REST API. Defaults to false
- saltext.snap.modules.snap_mod.list_upgrades(exclude_held=False)[source]¶
List available upgrades.
CLI Example:
salt '*' snap.list_upgrades
- exclude_held
Don’t list held snaps as upgradable. Defaults to False.
- saltext.snap.modules.snap_mod.options(name, option=None)[source]¶
Get a snap’s configuration option(s). If a value has not been set, returns None.
CLI Example:
salt '*' snap.option core salt '*' snap.option core system.timezone
- name
The name of the snap.
- option
The name of the option. Nested keys are concatenated with a dot. Optional. If omitted, lists all configuration options.
- saltext.snap.modules.snap_mod.option_set(name, option, value)[source]¶
Set a snap configuration option.
CLI Example:
salt '*' snap.option_set system experimental.parallel-instances false
- name
The name of the snap.
- option
The name of the option. Nested keys are concatenated with a dot.
- value
The value to set.
- saltext.snap.modules.snap_mod.option_unset(name, option)[source]¶
Get a snap’s configuration option(s).
CLI Example:
salt '*' snap.option_unset system experimental.parallel-instances
- name
The name of the snap.
- option
The name of the option. Nested keys are concatenated with a dot.
- value
The value to set.
- saltext.snap.modules.snap_mod.purge(name, revision=None)[source]¶
Remove a snap without saving a snapshot of its data.
CLI Example:
salt '*' snap.purge hello-world
- name
The name of the snap.
- revision
Remove this revision only. Optional.
- saltext.snap.modules.snap_mod.refresh(name, channel=None, revision=None, classic=False)[source]¶
Upgrade an installed snap or change some installation parameters.
CLI Example:
salt '*' snap.info hello-world
- name
The name of the snap.
- channel
Follow this channel instead of stable.
- revision
Install this revision instead of the latest one available in the channel.
- classic
Enable classic mode and disable security confinement. Defaults to false.
- saltext.snap.modules.snap_mod.remove(name, revision=None, purge=False)[source]¶
Remove a snap.
CLI Example:
salt '*' snap.remove hello-world
- name
The name of the snap.
- revision
Remove this revision only. Optional.
- purge
Don’t save a snapshot of its data. Defaults to false.
- saltext.snap.modules.snap_mod.service_enabled(name)[source]¶
Check if a snap’s service is enabled to run at boot.
CLI Example:
salt '*' snap.service_enabled yubioath-desktop.pcscd
- name
The name of the snap.
- saltext.snap.modules.snap_mod.service_running(name)[source]¶
Check if a snap’s service is currently running.
CLI Example:
salt '*' snap.service_running yubioath-desktop.pcscd
- name
The name of the snap.
- saltext.snap.modules.snap_mod.service_start(name, enable=False)[source]¶
Start a snap’s service(s).
CLI Example:
salt '*' snap.service_start yubioath-desktop.pcscd salt '*' snap.service_start yubioath-desktop
- name
The name of the snap or one of its services.
- saltext.snap.modules.snap_mod.service_stop(name, disable=False)[source]¶
Stop a snap’s service(s).
CLI Example:
salt '*' snap.service_stop yubioath-desktop.pcscd salt '*' snap.service_stop yubioath-desktop
- name
The name of the snap or one of its services.
- saltext.snap.modules.snap_mod.service_restart(name, reload=False)[source]¶
Restart a snap’s service(s).
CLI Example:
salt '*' snap.service_restart yubioath-desktop.pcscd salt '*' snap.service_restart yubioath-desktop
- name
The name of the snap or one of its services.
- saltext.snap.modules.snap_mod.services(name=None, snap=None)[source]¶
List snap services and their status.
CLI Example:
salt '*' snap.services
- name
Only return information about this specific service.
- snap
Only return information about services that belong to this snap.
- saltext.snap.modules.snap_mod.upgrade_all()[source]¶
Upgrade all snaps.
CLI Example:
salt '*' snap.upgrade_all
- class saltext.snap.modules.snap_mod.SnapdAdapter(pool_connections=10, pool_maxsize=10, max_retries=0, pool_block=False)[source]¶
- get_connection(url, proxies=None)[source]¶
DEPRECATED: Users should move to get_connection_with_tls_context for all subclasses of HTTPAdapter using Requests>=2.32.2.
Returns a urllib3 connection for the given URL. This should not be called from user code, and is only exposed for use when subclassing the
HTTPAdapter
.- Parameters:
url – The URL to connect to.
proxies – (optional) A Requests-style dictionary of proxies used on this request.
- Return type:
urllib3.ConnectionPool