1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-07-07 02:58:54 +00:00

snap: support system as a configuration target (#12025)

* feat(snap): support snap system configuration via name=system

Treat `system` as a virtual snap that is always considered installed,
bypassing snap info lookup and install/refresh logic, while still
allowing snap set/get operations via the options parameter.

Fixes #11266

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

* docs(snap): note version_added for system support; add changelog fragment

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-14 22:02:28 +12:00 committed by GitHub
parent fba7da4394
commit 862d7d7aaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 120 additions and 9 deletions

View file

@ -438,6 +438,90 @@ TEST_SPEC = dict(
],
),
),
dict(
id="set_system_option",
input={"name": ["system"], "options": ["proxy.http=http://proxy.example.com:3128/"]},
output=dict(changed=True, options_changed=["system:proxy.http=http://proxy.example.com:3128/"]),
flags={},
mocks=dict(
run_command=[
dict(
command=["/testbin/snap", "version"],
environ=default_env,
rc=0,
out=default_version_out,
err="",
),
# No "snap info system" — virtual snap bypasses names_from_snaps
dict(
command=["/testbin/snap", "list"],
environ=default_env,
rc=0,
out="",
err="",
),
dict(
command=["/testbin/snap", "get", "-d", "system"],
environ=default_env,
rc=0,
out="{}",
err="",
),
dict(
command=["/testbin/snap", "set", "system", "proxy.http=http://proxy.example.com:3128/"],
environ=default_env,
rc=0,
out="",
err="",
),
dict(
command=["/testbin/snap", "list"],
environ=default_env,
rc=0,
out="",
err="",
),
],
),
),
dict(
id="set_system_option_idempotent",
input={"name": ["system"], "options": ["proxy.http=http://proxy.example.com:3128/"]},
output=dict(changed=False),
flags={},
mocks=dict(
run_command=[
dict(
command=["/testbin/snap", "version"],
environ=default_env,
rc=0,
out=default_version_out,
err="",
),
dict(
command=["/testbin/snap", "list"],
environ=default_env,
rc=0,
out="",
err="",
),
dict(
command=["/testbin/snap", "get", "-d", "system"],
environ=default_env,
rc=0,
out='{"proxy": {"http": "http://proxy.example.com:3128/"}}',
err="",
),
dict(
command=["/testbin/snap", "list"],
environ=default_env,
rc=0,
out="",
err="",
),
],
),
),
dict(
id="issue_6803",
input={"name": ["microk8s", "kubectl"], "classic": True},