Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ooops! Snap installation failed while executing #7265

Closed
1 task done
onknows opened this issue Sep 15, 2023 · 28 comments · Fixed by #7340
Closed
1 task done

Ooops! Snap installation failed while executing #7265

onknows opened this issue Sep 15, 2023 · 28 comments · Fixed by #7340
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) traceback

Comments

@onknows
Copy link

onknows commented Sep 15, 2023

Summary

This is related to #7130 . This issue #7130 is still not completely fixed. The following code fails on Ubuntu 22.04. I tested this with 7.3.0, 7.4.0. It fails with those versions. The code below does however work when using 6.6.0.

    - name: Install packages
      ansible.builtin.apt:
        name:
          - snapd
          - fuse
          - udev
        state: present
        update_cache: true

    - name: Install Microk8s
      community.general.snap:
        name: microk8s
        classic: true
        channel: 1.26/stable
TASK [Install Microk8s] ********************************************************
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
fatal: [c2d-galaxy1]: FAILED! => changed=false 
  channel: 1.26/stable
  classic: true
  cmd: '[''state'', ''classic'', ''channel'', ''dangerous'', ''microk8s'']'
  msg: Ooops! Snap installation failed while executing '['state', 'classic', 'channel', 'dangerous', 'microk8s']', please examine logs and error output for more details.
  output:
    channel: 1.26/stable
    classic: true
    cmd: '[''state'', ''classic'', ''channel'', ''dangerous'', ''microk8s'']'
    snap_names:
    - microk8s
    snaps_installed:
    - microk8s
  snap_names:
  - microk8s
  snaps_installed:
  - microk8s
  vars:
    channel: 1.26/stable
    classic: true
    cmd: '[''state'', ''classic'', ''channel'', ''dangerous'', ''microk8s'']'
    snap_names:
    - microk8s
    snaps_installed:
    - microk8s

Issue Type

Bug Report

Component Name

snap

Ansible Version

θ97° [:ansible-dev]└2 master(+104/-29,-1)* 130 ± ansible --version
ansible [core 2.15.0]
  config file = /home/onknows/git/gitlab/c2/ansible-dev/ansible-dev.cfg
  configured module search path = ['/home/onknows/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/onknows/.virtualenv/c2d/lib/python3.10/site-packages/ansible
  ansible collection location = /home/onknows/git/gitlab/c2/ansible-dev-collections:/home/onknows/git/gitlab/c2/ansible-dev
  executable location = /home/onknows/.virtualenv/c2d/bin/ansible
  python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (/home/onknows/.virtualenv/c2d/bin/python)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

# /home/onknows/git/gitlab/c2/ansible-dev/ansible_collections
Collection        Version
----------------- -------
community.general 7.4.0 

Configuration

    - name: Install packages
      ansible.builtin.apt:
        name:
          - snapd
          - fuse
          - udev
        state: present
        update_cache: true

    - name: Install Microk8s
      community.general.snap:
        name: microk8s
        classic: true
        channel: 1.26/stable

OS / Environment

Ubuntu 22.04

Steps to Reproduce

---
- name: galaxy.yml
  hosts: galaxy
  become: yes

  tasks:

    - name: Install packages
      ansible.builtin.apt:
        name:
          - snapd
          - fuse
          - udev
        state: present
        update_cache: true

    - name: Install Microk8s
      community.general.snap:
        name: microk8s
        classic: true
        channel: 1.26/stable

Expected Results

Snap install like on community.general 6.6.0

Actual Results

TASK [Install Microk8s] ********************************************************
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
fatal: [c2d-galaxy1]: FAILED! => changed=false 
  channel: 1.26/stable
  classic: true
  cmd: '[''state'', ''classic'', ''channel'', ''dangerous'', ''microk8s'']'
  msg: Ooops! Snap installation failed while executing '['state', 'classic', 'channel', 'dangerous', 'microk8s']', please examine logs and error output for more details.
  output:
    channel: 1.26/stable
    classic: true
    cmd: '[''state'', ''classic'', ''channel'', ''dangerous'', ''microk8s'']'
    snap_names:
    - microk8s
    snaps_installed:
    - microk8s
  snap_names:
  - microk8s
  snaps_installed:
  - microk8s
  vars:
    channel: 1.26/stable
    classic: true
    cmd: '[''state'', ''classic'', ''channel'', ''dangerous'', ''microk8s'']'
    snap_names:
    - microk8s
    snaps_installed:
    - microk8s

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

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

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) traceback labels Sep 15, 2023
@felixfontein
Copy link
Collaborator

CC @russoz

@russoz
Copy link
Collaborator

russoz commented Sep 16, 2023

hi @onknows, thanks for reporting the issue.

Could you please paste the output of the playbook when running with -vvvv? TIA

@russoz
Copy link
Collaborator

russoz commented Sep 17, 2023

Also, could you please inform:

  • the version of snap you are using?
  • the OS distro and version in both the target node and the controller?
  • the full output of ansible-galaxy collection list community.general?

@russoz
Copy link
Collaborator

russoz commented Sep 17, 2023

For the record, the problem in #7130 was that the wrong version of the collection was being used. As soon as the user made sure the correct version (7.3.0 at the time), the problem was gone.

@onknows
Copy link
Author

onknows commented Sep 18, 2023

hi @onknows, thanks for reporting the issue.

Could you please paste the output of the playbook when running with -vvvv? TIA

See provision.log

vagrant@c2d-galaxy1:~$ snap --version
snap    2.60.3
snapd   2.60.3
series  16
ubuntu  22.04
kernel  6.2.0-32-generic

Controller node

onknows@io3:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
onknows@io3:~$ 

Target node:

vagrant@c2d-galaxy1:~$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
vagrant@c2d-galaxy1:~$ 

Full list:

le-dev]└2 master(+13/-11)* ± ansible-galaxy collection list community.general

# /home/onknows/git/gitlab/c2/ansible-dev/ansible_collections
Collection        Version
----------------- -------
community.general 7.3.0  
θ100° [:ansible-dev]└2 master(+29/-8)* ± 

@russoz
Copy link
Collaborator

russoz commented Sep 18, 2023

Hi @onknows , thanks for the extra info. However, in the output file you attached, I do not see in the output of the module a variable run_info that is only set when using -vvvv (4 times). If you indeed used -vvvv, that would be an indication that maybe we have a different version of the module being used somehow.

Could you please double check and ensure that we have run_info in the output? As an example you can see in #7130 (comment) how the output should look like.

@onknows
Copy link
Author

onknows commented Sep 19, 2023

Hi @russoz, my bad, I did not see four v, below is the log with -vvvv
provision.log

@Voldemat
Copy link

Encountered the same problem

@Voldemat
Copy link

@russoz Hi, is there any news on that?

@russoz
Copy link
Collaborator

russoz commented Sep 27, 2023

Hi @Voldemat , sorry, haven't had time to work on it these last days. Hopefully on the weekend.

@utamas
Copy link

utamas commented Sep 30, 2023

@russoz is there any awy I can help? I'm also hitting this issue

@sineverba
Copy link

Got same issue @russoz

@utamas
Copy link

utamas commented Sep 30, 2023

provision.log

@russoz
Copy link
Collaborator

russoz commented Oct 2, 2023

Ok, the errors that we have been seeing are coming up during the installation of the snaps. The way the module works today is:

  1. Detect the installed snaps
  2. Install (if needed)

Parsing the installation output to detect whether it was successful or not. However, that seems to be proving less straightforward than expected, so I am changing the logic to:

  1. Detect the installed snaps
  2. Install (if needed)
  3. Detect the final state (and compare with the initial one)

The snap command is not fast (it takes a couple of seconds just to start) and that extra call will be noticed, but it is more reliable that way.

@russoz
Copy link
Collaborator

russoz commented Oct 2, 2023

hi all,

Please check whether the code in the PR #7340 solves your problem.

As I never got to replicate the problem, I am not confident it does.

Cheers,
AZ

@russoz
Copy link
Collaborator

russoz commented Oct 2, 2023

@sineverba
Copy link

@russoz I can test it in some day, but... how can I test it?

@russoz
Copy link
Collaborator

russoz commented Oct 2, 2023

In an isolated environment, install it with:

ansible-galaxy collection install git+https://github.com/russoz-ansible/community.general.git,snap-fix

Alternatively, if you don't mind getting your hands dirty, you could clone my fork and manually copy the snap.py file into your current installation, provided you remember to revert that later ;-)

@sineverba
Copy link

No problem for hands dirty. I use Ansible in Docker ;)

@russoz
Copy link
Collaborator

russoz commented Oct 3, 2023

Please let us know if/when you manage to replicate the situation using the updated module.

@sineverba
Copy link

Probably I can test not before the weekend.

@utamas
Copy link

utamas commented Oct 4, 2023

I'll try shortly.

@sineverba
Copy link

ERROR! Could not find git executable to extract the collection from the Git repository https://github.com/russoz-ansible/community.general.git.

@utamas
Copy link

utamas commented Oct 4, 2023

So I copied snap.py and I can confirm that it works like a charm. Thank you @russoz

@russoz
Copy link
Collaborator

russoz commented Oct 4, 2023

ERROR! Could not find git executable to extract the collection from the Git repository https://github.com/russoz-ansible/community.general.git

Yup, ansible-galaxy will require git to be installed when installing directly from the repository.

@sineverba
Copy link

sineverba commented Oct 5, 2023

Finally I setup via ansible-galaxy and it works ;)

Thank you @russoz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants