snap: add devmode parameter to support --devmode flag (#11952)

* feat(snap): add devmode parameter to support --devmode flag

Closes #8155

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(changelog): add fragment for PR 11952

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexei Znamensky
2026-05-02 10:46:23 +12:00
committed by GitHub
parent 881f64c93b
commit e751412914
3 changed files with 12 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
minor_changes:
- snap - add ``devmode`` option to support installing snaps in developer mode (https://github.com/ansible-collections/community.general/pull/11952, https://github.com/ansible-collections/community.general/issues/8155).

View File

@@ -47,6 +47,7 @@ def snap_runner(module: AnsibleModule, **kwargs) -> CmdRunner:
options=cmd_runner_fmt.as_list(), options=cmd_runner_fmt.as_list(),
info=cmd_runner_fmt.as_fixed("info"), info=cmd_runner_fmt.as_fixed("info"),
dangerous=cmd_runner_fmt.as_bool("--dangerous"), dangerous=cmd_runner_fmt.as_bool("--dangerous"),
devmode=cmd_runner_fmt.as_bool("--devmode"),
version=cmd_runner_fmt.as_fixed("version"), version=cmd_runner_fmt.as_fixed("version"),
_connect=cmd_runner_fmt.as_func(lambda v: ["connect", v]), _connect=cmd_runner_fmt.as_func(lambda v: ["connect", v]),
_disconnect=cmd_runner_fmt.as_func(lambda v: ["disconnect", v]), _disconnect=cmd_runner_fmt.as_func(lambda v: ["disconnect", v]),

View File

@@ -77,6 +77,13 @@ options:
type: bool type: bool
default: false default: false
version_added: 7.2.0 version_added: 7.2.0
devmode:
description:
- Install the snap in developer mode, granting the snap full system access and disabling security confinement.
- See U(https://snapcraft.io/docs/install-modes) for more details about installation modes.
type: bool
default: false
version_added: 13.0.0
notes: notes:
- Privileged operations, such as installing and configuring snaps, require root priviledges. This is only the case if the - Privileged operations, such as installing and configuring snaps, require root priviledges. This is only the case if the
user has not logged in to the Snap Store. user has not logged in to the Snap Store.
@@ -194,6 +201,7 @@ class Snap(StateModuleHelper):
"channel": dict(type="str"), "channel": dict(type="str"),
"options": dict(type="list", elements="str"), "options": dict(type="list", elements="str"),
"dangerous": dict(type="bool", default=False), "dangerous": dict(type="bool", default=False),
"devmode": dict(type="bool", default=False),
}, },
supports_check_mode=True, supports_check_mode=True,
) )
@@ -390,7 +398,7 @@ class Snap(StateModuleHelper):
if self.check_mode: if self.check_mode:
return return
params = ["state", "classic", "channel", "dangerous"] # get base cmd parts params = ["state", "classic", "channel", "dangerous", "devmode"] # get base cmd parts
has_one_pkg_params = bool(self.vars.classic) or self.vars.channel != "stable" has_one_pkg_params = bool(self.vars.classic) or self.vars.channel != "stable"
has_multiple_snaps = len(actionable_snaps) > 1 has_multiple_snaps = len(actionable_snaps) > 1