1

I have this simple task in my ansible playbook for installation WPS Office via snap:

- name: "Install WPS Office"
  snap: 
    name: wps-office

But it fails with the error:

TASK [Install WPS Office] *********************************************************************************************
task path: /home/anton/ansible/roles/wps-office/tasks/install.yml:4
redirecting (type: modules) ansible.builtin.snap to community.general.snap
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: anton
<localhost> EXEC /bin/sh -c 'echo ~anton && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/anton/.ansible/tmp `"&& mkdir "` echo /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114 `" && echo ansible-tmp-1688299651.1242838-18662-118187479744114="` echo /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114 `" ) && sleep 0'
redirecting (type: modules) ansible.builtin.snap to community.general.snap
Using module file /home/anton/.ansible/collections/ansible_collections/community/general/plugins/modules/snap.py
<localhost> PUT /home/anton/.ansible/tmp/ansible-local-185496p_gs6vg/tmp_e3ocvey TO /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114/AnsiballZ_snap.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114/ /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114/AnsiballZ_snap.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114/AnsiballZ_snap.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/anton/.ansible/tmp/ansible-tmp-1688299651.1242838-18662-118187479744114/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_snap_payload_nl3bus9k/ansible_snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/deco.py", line 52, in wrapper
    func(self, *args, **kwargs)
  File "/tmp/ansible_snap_payload_nl3bus9k/ansible_snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/base.py", line 80, in run
    self.__run__()
  File "/tmp/ansible_snap_payload_nl3bus9k/ansible_snap_payload.zip/ansible_collections/community/general/plugins/module_utils/mh/mixins/state.py", line 37, in __run__
    return func()
           ^^^^^^
  File "/tmp/ansible_snap_payload_nl3bus9k/ansible_snap_payload.zip/ansible_collections/community/general/plugins/modules/snap.py", line 353, in state_present
  File "/tmp/ansible_snap_payload_nl3bus9k/ansible_snap_payload.zip/ansible_collections/community/general/plugins/modules/snap.py", line 341, in _present
  File "/tmp/ansible_snap_payload_nl3bus9k/ansible_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": null,
    "classic": false,
    "cmd": "['state', 'classic', 'channel', 'wps-office']",
    "invocation": {
        "module_args": {
            "channel": null,
            "classic": false,
            "name": [
                "wps-office"
            ],
            "options": null,
            "state": "present"
        }
    },
    "msg": "Ooops! Snap installation failed while executing '['state', 'classic', 'channel', 'wps-office']', please examine logs and error output for more details.",
    "output": {
        "channel": null,
        "classic": false,
        "cmd": "['state', 'classic', 'channel', 'wps-office']",
        "snaps_installed": [
            "wps-office"
        ]
    },
    "snaps_installed": [
        "wps-office"
    ],
    "vars": {
        "channel": null,
        "classic": false,
        "cmd": "['state', 'classic', 'channel', 'wps-office']",
        "snaps_installed": [
            "wps-office"
        ]
    }
}

But despite the error, the program was installed:

$ snap info wps-office

name:      wps-office
summary:   WPS Office Suite
publisher: liuyang8
store-url: https://snapcraft.io/wps-office
license:   unset
description: |
  WPS Office, is an office productivity suite.
  WPS Office including Writer, Presentation
  and Spreadsheets, is a powerful office suite, which is able to process
  word file, produce wonderful slides, and analyze data as well. It is
  deeply compatible with all of the latest Microsoft Office file formats.
  It can easily open and read the documents created with Microsoft Office.
  This is the Linux version, and it's now a TESTING package.
  Welcome to our website: http://wps-community.org
snap-id: fTF2opFpkHPihObSECzYPMyYbVfi9G4u
channels:
  latest/stable:    10.1.0.6757 2018-09-11 (1) 250MB -
  latest/candidate: ↑                                
  latest/beta:      ↑                                
  latest/edge:      ↑

I'm getting the same error for any other snap package, not only for wps-office. Ansible version 2.14.2.

Do you have any ideas what might be the cause of the error?

27cm
  • 23
  • 1
  • 5

1 Answers1

0

Looks like it has something to do with setting the correct channel. Previously my ansible task was:

community.general.snap:
  name: go
  classic: yes
  channel: stable
  state: present

But that began failing, on the box itself I looked at the installed snaps:

$ snap list
Name    Version        Rev    Tracking       Publisher   Notes
core20  20230622       1974   latest/stable  canonical✓  base
core22  20230629       806    latest/stable  canonical✓  base
go      1.20.5         10199  latest/stable  canonical✓  classic

Confusingly Tracking == channel. Updated my ansible role to:

channel: 'latest/stable'

And the task began working again

(tested on ansible 2.15.1, Ubuntu 20.04 LTS)

xref
  • 1,707
  • 5
  • 19
  • 41
  • I've tried to add `channel: 'latest/stable'` and it still isn't working. Ubuntu 23.04. – 27cm Jul 12 '23 at 21:56
  • @27cm Did you happen to run `snap list` to verify that’s the exact channel you’re Tracking? – xref Jul 13 '23 at 01:03