Repository: ansible-collections/community.general

Issue:
Failed to install snap package: snap \"shellcheck\" has no updates available
### Summary

After the upgrade  of the community.general to version 7.1.0, the installation of a snap package that is already present failed. Reverting community.general to version 7.0.1 solved the issue.

### Issue Type

Bug Report

### Component Name

snap

### Ansible Version

```console (paste below)
$ ansible --version
ansible [core 2.14.6]
  config file = None
  configured module search path = ['/home/ltshb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible
  ansible collection location = /home/ltshb/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
```


### Community.general Version

```console (paste below)
$ ansible-galaxy collection list community.general
# /home/ltshb/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 7.1.0  

# /usr/local/lib/python3.10/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.5.0  

```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed
CONFIG_FILE() = None
```


### OS / Environment

Ubuntu 22.04

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
- name: Install latest shellcheck
  become: true
  community.general.snap:
    channel: edge
    name: shellcheck

```


### Expected Results

No error, the package is already installed and ansible task should be green

### Actual Results

```console (paste below)
TASK [shelltool : Install latest shellcheck] ****************************************************************************************
task path: .../roles/shelltool/tasks/main.yml:9
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ltshb
<localhost> EXEC /bin/sh -c 'echo ~ltshb && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ltshb/.ansible/tmp `"&& mkdir "` echo /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014 `" && echo ansible-tmp-1688130988.6489294-134720-233180584502014="` echo /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014 `" ) && sleep 0'
Using module file /home/ltshb/.ansible/collections/ansible_collections/community/general/plugins/modules/snap.py
<localhost> PUT /home/ltshb/.ansible/tmp/ansible-local-130699sd05x0z9/tmp8536jboh TO /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014/AnsiballZ_snap.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014/ /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014/AnsiballZ_snap.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -p "[sudo via ansible, key=zzvldjejqxzpyurrmtyqjpbziykqtzsl] password:" -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-zzvldjejqxzpyurrmtyqjpbziykqtzsl ; GOBIN=/usr/local/bin PATH=/home/ltshb/.local/bin:/home/ltshb/.nvm/versions/node/v16.20.0/bin:/home/ltshb/.local/bin:/home/ltshb/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/go/bin /usr/bin/python3 /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014/AnsiballZ_snap.py'"'"' && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/ltshb/.ansible/tmp/ansible-tmp-1688130988.6489294-134720-233180584502014/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.general.snap_payload_q4svvtq3/ansible_community.general.snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/deco.py", line 52, in wrapper
    func(self, *args, **kwargs)
  File "/tmp/ansible_community.general.snap_payload_q4svvtq3/ansible_community.general.snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/base.py", line 80, in run
    self.__run__()
  File "/tmp/ansible_community.general.snap_payload_q4svvtq3/ansible_community.general.snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/mixins/state.py", line 37, in __run__
    return func()
  File "/tmp/ansible_community.general.snap_payload_q4svvtq3/ansible_community.general.snap_payload.zip/ansible_collections/community/general/plugins/modules/snap.py", line 350, in state_present
  File "/tmp/ansible_community.general.snap_payload_q4svvtq3/ansible_community.general.snap_payload.zip/ansible_collections/community/general/plugins/modules/snap.py", line 341, in _present
  File "/tmp/ansible_community.general.snap_payload_q4svvtq3/ansible_community.general.snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/base.py", line 40, in do_raise
    raise _MHE(*args, **kwargs)
ansible_collections.community.general.plugins.module_utils.mh.exceptions.ModuleHelperException
fatal: [localhost]: FAILED! => {
    "changed": false,
    "channel": "edge",
    "classic": false,
    "cmd": "['state', 'classic', 'channel', 'shellcheck']",
    "invocation": {
        "module_args": {
            "channel": "edge",
            "classic": false,
            "name": [
                "shellcheck"
            ],
            "options": null,
            "state": "present"
        }
    },
    "msg": "Ooops! Snap installation failed while executing '['state', 'classic', 'channel', 'shellcheck']', please examine logs and error output for more details.",
    "output": {
        "channel": "edge",
        "classic": false,
        "cmd": "['state', 'classic', 'channel', 'shellcheck']",
        "run_info": [
            {
                "args_order": [
                    "state",
                    "classic",
                    "channel",
                    "name"
                ],
                "check_rc": false,
                "cmd": [
                    "/usr/bin/snap",
                    "refresh",
                    "--channel",
                    "edge",
                    "shellcheck"
                ],
                "context_run_args": {
                    "name": [
                        "shellcheck"
                    ],
                    "state": "refresh"
                },
                "environ_update": {
                    "LANGUAGE": "C",
                    "LC_ALL": "C"
                },
                "ignore_value_none": true,
                "results_err": "snap \"shellcheck\" has no updates available\n",
                "results_out": "",
                "results_processed": [
                    0,
                    "",
                    "snap \"shellcheck\" has no updates available\n"
                ],
                "results_rc": 0,
                "run_command_args": {
                    "check_rc": false,
                    "environ_update": {
                        "LANGUAGE": "C",
                        "LC_ALL": "C"
                    }
                }
            }
        ],
        "snaps_installed": [
            "shellcheck"
        ],
        "status_out": [
            [
                "bare",
                "latest/stable"
            ],
            [
                "core18",
                "latest/stable"
            ],
            [
                "core20",
                "latest/stable"
            ],
            [
                "core22",
                "latest/stable"
            ],
            [
                "firefox",
                "latest/stable/…"
            ],
            [
                "gnome-3-34-1804",
                "latest/stable"
            ],
            [
                "gnome-3-38-2004",
                "latest/stable/…"
            ],
            [
                "gnome-42-2204",
                "latest/stable"
            ],
            [
                "gtk-common-themes",
                "latest/stable/…"
            ],
            [
                "shellcheck",
                "latest/edge"
            ],
            [
                "slack",
                "latest/stable"
            ],
            [
                "snap-store",
                "latest/stable/…"
            ],
            [
                "snapd",
                "latest/stable"
            ],
            [
                "snapd-desktop-integration",
                "latest/stable/…"
            ],
            [
                "yq",
                "latest/stable"
            ]
        ],
        "status_run_info": {
            "args_order": [
                "_list"
            ],
            "check_rc": false,
            "cmd": [
                "/usr/bin/snap",
                "list"
            ],
            "context_run_args": {
                "check_rc": true
            },
            "environ_update": {
                "LANGUAGE": "C",
                "LC_ALL": "C"
            },
            "ignore_value_none": true,
            "results_err": "",
            "results_out": "Name                       Version           Rev    Tracking         Publisher    Notes\nbare                       1.0               5      latest/stable    canonical**  base\ncore18                     20230530          2785   latest/stable    canonical**  base\ncore20                     20230613          1950   latest/stable    canonical**  base\ncore22                     20230612          766    latest/stable    canonical**  base\nfirefox                    114.0.2-1         2800   latest/stable/…  mozilla**    -\ngnome-3-34-1804            0+git.3556cb3     93     latest/stable    canonical**  -\ngnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -\ngnome-42-2204              0+git.ff35a85     111    latest/stable    canonical**  -\ngtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -\nshellcheck                 v0.9.0            1709   latest/edge      koalaman     -\nslack                      4.32.127          79     latest/stable    slack**      -\nsnap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -\nsnapd                      2.59.5            19457  latest/stable    canonical**  snapd\nsnapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -\nyq                         v4.34.1           2194   latest/stable    mikefarah    -\n",
            "results_processed": [
                0,
                "Name                       Version           Rev    Tracking         Publisher    Notes\nbare                       1.0               5      latest/stable    canonical**  base\ncore18                     20230530          2785   latest/stable    canonical**  base\ncore20                     20230613          1950   latest/stable    canonical**  base\ncore22                     20230612          766    latest/stable    canonical**  base\nfirefox                    114.0.2-1         2800   latest/stable/…  mozilla**    -\ngnome-3-34-1804            0+git.3556cb3     93     latest/stable    canonical**  -\ngnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -\ngnome-42-2204              0+git.ff35a85     111    latest/stable    canonical**  -\ngtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -\nshellcheck                 v0.9.0            1709   latest/edge      koalaman     -\nslack                      4.32.127          79     latest/stable    slack**      -\nsnap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -\nsnapd                      2.59.5            19457  latest/stable    canonical**  snapd\nsnapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -\nyq                         v4.34.1           2194   latest/stable    mikefarah    -\n",
                ""
            ],
            "results_rc": 0,
            "run_command_args": {
                "check_rc": false,
                "environ_update": {
                    "LANGUAGE": "C",
                    "LC_ALL": "C"
                }
            }
        }
    },
    "run_info": [
        {
            "args_order": [
                "state",
                "classic",
                "channel",
                "name"
            ],
            "check_rc": false,
            "cmd": [
                "/usr/bin/snap",
                "refresh",
                "--channel",
                "edge",
                "shellcheck"
            ],
            "context_run_args": {
                "name": [
                    "shellcheck"
                ],
                "state": "refresh"
            },
            "environ_update": {
                "LANGUAGE": "C",
                "LC_ALL": "C"
            },
            "ignore_value_none": true,
            "results_err": "snap \"shellcheck\" has no updates available\n",
            "results_out": "",
            "results_processed": [
                0,
                "",
                "snap \"shellcheck\" has no updates available\n"
            ],
            "results_rc": 0,
            "run_command_args": {
                "check_rc": false,
                "environ_update": {
                    "LANGUAGE": "C",
                    "LC_ALL": "C"
                }
            }
        }
    ],
    "snaps_installed": [
        "shellcheck"
    ],
    "status_out": [
        [
            "bare",
            "latest/stable"
        ],
        [
            "core18",
            "latest/stable"
        ],
        [
            "core20",
            "latest/stable"
        ],
        [
            "core22",
            "latest/stable"
        ],
        [
            "firefox",
            "latest/stable/…"
        ],
        [
            "gnome-3-34-1804",
            "latest/stable"
        ],
        [
            "gnome-3-38-2004",
            "latest/stable/…"
        ],
        [
            "gnome-42-2204",
            "latest/stable"
        ],
        [
            "gtk-common-themes",
            "latest/stable/…"
        ],
        [
            "shellcheck",
            "latest/edge"
        ],
        [
            "slack",
            "latest/stable"
        ],
        [
            "snap-store",
            "latest/stable/…"
        ],
        [
            "snapd",
            "latest/stable"
        ],
        [
            "snapd-desktop-integration",
            "latest/stable/…"
        ],
        [
            "yq",
            "latest/stable"
        ]
    ],
    "status_run_info": {
        "args_order": [
            "_list"
        ],
        "check_rc": false,
        "cmd": [
            "/usr/bin/snap",
            "list"
        ],
        "context_run_args": {
            "check_rc": true
        },
        "environ_update": {
            "LANGUAGE": "C",
            "LC_ALL": "C"
        },
        "ignore_value_none": true,
        "results_err": "",
        "results_out": "Name                       Version           Rev    Tracking         Publisher    Notes\nbare                       1.0               5      latest/stable    canonical**  base\ncore18                     20230530          2785   latest/stable    canonical**  base\ncore20                     20230613          1950   latest/stable    canonical**  base\ncore22                     20230612          766    latest/stable    canonical**  base\nfirefox                    114.0.2-1         2800   latest/stable/…  mozilla**    -\ngnome-3-34-1804            0+git.3556cb3     93     latest/stable    canonical**  -\ngnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -\ngnome-42-2204              0+git.ff35a85     111    latest/stable    canonical**  -\ngtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -\nshellcheck                 v0.9.0            1709   latest/edge      koalaman     -\nslack                      4.32.127          79     latest/stable    slack**      -\nsnap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -\nsnapd                      2.59.5            19457  latest/stable    canonical**  snapd\nsnapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -\nyq                         v4.34.1           2194   latest/stable    mikefarah    -\n",
        "results_processed": [
            0,
            "Name                       Version           Rev    Tracking         Publisher    Notes\nbare                       1.0               5      latest/stable    canonical**  base\ncore18                     20230530          2785   latest/stable    canonical**  base\ncore20                     20230613          1950   latest/stable    canonical**  base\ncore22                     20230612          766    latest/stable    canonical**  base\nfirefox                    114.0.2-1         2800   latest/stable/…  mozilla**    -\ngnome-3-34-1804            0+git.3556cb3     93     latest/stable    canonical**  -\ngnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -\ngnome-42-2204              0+git.ff35a85     111    latest/stable    canonical**  -\ngtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -\nshellcheck                 v0.9.0            1709   latest/edge      koalaman     -\nslack                      4.32.127          79     latest/stable    slack**      -\nsnap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -\nsnapd                      2.59.5            19457  latest/stable    canonical**  snapd\nsnapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -\nyq                         v4.34.1           2194   latest/stable    mikefarah    -\n",
            ""
        ],
        "results_rc": 0,
        "run_command_args": {
            "check_rc": false,
            "environ_update": {
                "LANGUAGE": "C",
                "LC_ALL": "C"
            }
        }
    },
    "vars": {
        "channel": "edge",
        "classic": false,
        "cmd": "['state', 'classic', 'channel', 'shellcheck']",
        "run_info": [
            {
                "args_order": [
                    "state",
                    "classic",
                    "channel",
                    "name"
                ],
                "check_rc": false,
                "cmd": [
                    "/usr/bin/snap",
                    "refresh",
                    "--channel",
                    "edge",
                    "shellcheck"
                ],
                "context_run_args": {
                    "name": [
                        "shellcheck"
                    ],
                    "state": "refresh"
                },
                "environ_update": {
                    "LANGUAGE": "C",
                    "LC_ALL": "C"
                },
                "ignore_value_none": true,
                "results_err": "snap \"shellcheck\" has no updates available\n",
                "results_out": "",
                "results_processed": [
                    0,
                    "",
                    "snap \"shellcheck\" has no updates available\n"
                ],
                "results_rc": 0,
                "run_command_args": {
                    "check_rc": false,
                    "environ_update": {
                        "LANGUAGE": "C",
                        "LC_ALL": "C"
                    }
                }
            }
        ],
        "snaps_installed": [
            "shellcheck"
        ],
        "status_out": [
            [
                "bare",
                "latest/stable"
            ],
            [
                "core18",
                "latest/stable"
            ],
            [
                "core20",
                "latest/stable"
            ],
            [
                "core22",
                "latest/stable"
            ],
            [
                "firefox",
                "latest/stable/…"
            ],
            [
                "gnome-3-34-1804",
                "latest/stable"
            ],
            [
                "gnome-3-38-2004",
                "latest/stable/…"
            ],
            [
                "gnome-42-2204",
                "latest/stable"
            ],
            [
                "gtk-common-themes",
                "latest/stable/…"
            ],
            [
                "shellcheck",
                "latest/edge"
            ],
            [
                "slack",
                "latest/stable"
            ],
            [
                "snap-store",
                "latest/stable/…"
            ],
            [
                "snapd",
                "latest/stable"
            ],
            [
                "snapd-desktop-integration",
                "latest/stable/…"
            ],
            [
                "yq",
                "latest/stable"
            ]
        ],
        "status_run_info": {
            "args_order": [
                "_list"
            ],
            "check_rc": false,
            "cmd": [
                "/usr/bin/snap",
                "list"
            ],
            "context_run_args": {
                "check_rc": true
            },
            "environ_update": {
                "LANGUAGE": "C",
                "LC_ALL": "C"
            },
            "ignore_value_none": true,
            "results_err": "",
            "results_out": "Name                       Version           Rev    Tracking         Publisher    Notes\nbare                       1.0               5      latest/stable    canonical**  base\ncore18                     20230530          2785   latest/stable    canonical**  base\ncore20                     20230613          1950   latest/stable    canonical**  base\ncore22                     20230612          766    latest/stable    canonical**  base\nfirefox                    114.0.2-1         2800   latest/stable/…  mozilla**    -\ngnome-3-34-1804            0+git.3556cb3     93     latest/stable    canonical**  -\ngnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -\ngnome-42-2204              0+git.ff35a85     111    latest/stable    canonical**  -\ngtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -\nshellcheck                 v0.9.0            1709   latest/edge      koalaman     -\nslack                      4.32.127          79     latest/stable    slack**      -\nsnap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -\nsnapd                      2.59.5            19457  latest/stable    canonical**  snapd\nsnapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -\nyq                         v4.34.1           2194   latest/stable    mikefarah    -\n",
            "results_processed": [
                0,
                "Name                       Version           Rev    Tracking         Publisher    Notes\nbare                       1.0               5      latest/stable    canonical**  base\ncore18                     20230530          2785   latest/stable    canonical**  base\ncore20                     20230613          1950   latest/stable    canonical**  base\ncore22                     20230612          766    latest/stable    canonical**  base\nfirefox                    114.0.2-1         2800   latest/stable/…  mozilla**    -\ngnome-3-34-1804            0+git.3556cb3     93     latest/stable    canonical**  -\ngnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -\ngnome-42-2204              0+git.ff35a85     111    latest/stable    canonical**  -\ngtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -\nshellcheck                 v0.9.0            1709   latest/edge      koalaman     -\nslack                      4.32.127          79     latest/stable    slack**      -\nsnap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -\nsnapd                      2.59.5            19457  latest/stable    canonical**  snapd\nsnapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -\nyq                         v4.34.1           2194   latest/stable    mikefarah    -\n",
                ""
            ],
            "results_rc": 0,
            "run_command_args": {
                "check_rc": false,
                "environ_update": {
                    "LANGUAGE": "C",
                    "LC_ALL": "C"
                }
            }
        }
    }
}

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/snap.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/snap.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @angristan @vcarceler
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
+1 I also ran into this. Pinning to 7.0.1 fixes it.

```
amazon-ebs.ubuntu: TASK [common : Install SSM Agent via snap] *************************************
    amazon-ebs.ubuntu: An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible_collections.community.general.plugins.module_utils.mh.exceptions.ModuleHelperException
    amazon-ebs.ubuntu: fatal: [default]: FAILED! => {"changed": false, "channel": "candidate", "classic": true, "cmd": "['state', 'classic', 'channel', 'amazon-ssm-agent']", "msg": "Ooops! Snap installation failed while executing '['state', 'classic', 'channel', 'amazon-ssm-agent']', please examine logs and error output for more details.", "output": {"channel": "candidate", "classic": true, "cmd": "['state', 'classic', 'channel', 'amazon-ssm-agent']", "snaps_installed": ["amazon-ssm-agent"]}, "snaps_installed": ["amazon-ssm-agent"], "vars": {"channel": "candidate", "classic": true, "cmd": "['state', 'classic', 'channel', 'amazon-ssm-agent']", "snaps_installed": ["amazon-ssm-agent"]}}
```
@ltshb I jsut managed to reproduce your error, should be working in a fix in the next couple of days or so.
@bgrande12 thanks for reporting. Could you please repeat the error using `-vvvv` to produce debugging information and paste that either here or in a gist/pastebin? TIA

Resolving patch:
diff --git a/plugins/modules/snap.py b/plugins/modules/snap.py
--- a/plugins/modules/snap.py
+++ b/plugins/modules/snap.py
@@ -55,6 +55,9 @@
             - 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.
             - If not passed, the C(snap) command will default to V(stable).
+            - If the value passed does not contain the C(track), it will default to C(latest).
+              For example, if V(edge) is passed, the module will assume the channel to be V(latest/edge).
+            - See U(https://snapcraft.io/docs/channels) for more details about snap channels.
         type: str
         required: false
     options:
@@ -277,7 +280,7 @@ def _status_check(name, channel, installed):
             match = [c for n, c in installed if n == name]
             if not match:
                 return Snap.NOT_INSTALLED
-            if channel and channel != match[0]:
+            if channel and match[0] not in (channel, "latest/{0}".format(channel)):
                 return Snap.CHANNEL_MISMATCH
             else:
                 return Snap.INSTALLED


Test patch:
diff --git a/tests/integration/targets/snap/tasks/test_channel.yml b/tests/integration/targets/snap/tasks/test_channel.yml
--- a/tests/integration/targets/snap/tasks/test_channel.yml
+++ b/tests/integration/targets/snap/tasks/test_channel.yml
@@ -44,3 +44,36 @@
       - install_microk8s_chan is changed
       - install_microk8s_chan_again is not changed
       - remove_microk8s is changed
+
+- name: Install package (shellcheck)
+  community.general.snap:
+    name: shellcheck
+    state: present
+  register: install_shellcheck
+
+- name: Install package with channel (shellcheck)
+  community.general.snap:
+    name: shellcheck
+    channel: edge
+    state: present
+  register: install_shellcheck_chan
+
+- name: Install package with channel (shellcheck) again
+  community.general.snap:
+    name: shellcheck
+    channel: edge
+    state: present
+  register: install_shellcheck_chan_again
+
+- name: Remove package (shellcheck)
+  community.general.snap:
+    name: shellcheck
+    state: absent
+  register: remove_shellcheck
+
+- assert:
+    that:
+      - install_shellcheck is changed
+      - install_shellcheck_chan is changed
+      - install_shellcheck_chan_again is not changed
+      - remove_shellcheck is changed