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

community.general.snap fails on 7.3.0 when list of packages is empty #7120

Closed
1 task done
amartin3225 opened this issue Aug 15, 2023 · 3 comments · Fixed by #7124
Closed
1 task done

community.general.snap fails on 7.3.0 when list of packages is empty #7120

amartin3225 opened this issue Aug 15, 2023 · 3 comments · Fixed by #7124
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@amartin3225
Copy link

Summary

When attempting to install a list of snap packages, if the list of snap packages is empty, an error is thrown and the playbook execution fails.

Issue Type

Bug Report

Component Name

snap

Ansible Version

$ ansible --version
ansible [core 2.14.5]
  config file = /home/<snip>/playbooks/ansible.cfg
  configured module search path = ['/usr/share/ansible/plugins/modules', '/home/<snip>/playbooks/library']
  ansible python module location = /home/<snip>/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/<snip>/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/<snip>/.local/bin/ansible
  python version = 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /home/<snip>/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 7.3.0

# /home/<snip>/.local/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 6.5.0

Configuration

 $ ansible-config dump --only-changed
CONFIG_FILE() = /home/<snip>/playbooks/ansible.cfg
DEFAULT_FORCE_HANDLERS(/home/<snip>/playbooks/ansible.cfg) = True
DEFAULT_MODULE_PATH(/home/<snip>/playbooks/ansible.cfg) = ['/usr/share/ansible/plugins/modules', '/home/<snip>/playbooks/library']
DEFAULT_STDOUT_CALLBACK(/home/<snip>/playbooks/ansible.cfg) = yaml
DISPLAY_SKIPPED_HOSTS(/home/<snip>/playbooks/ansible.cfg) = False
INJECT_FACTS_AS_VARS(/home/<snip>/playbooks/ansible.cfg) = True
RETRY_FILES_ENABLED(/home/<snip>/playbooks/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/home/<snip>/playbooks/ansible.cfg) = always

OS / Environment

Ubuntu 22.04

Steps to Reproduce

defaults/main.yml:

snap_packages: []

tasks/main.yml:

- name: install snap packages
  community.general.snap:
    name: "{{ snap_packages }}"

Expected Results

I expected the playbook to complete successfully (even though no packages will be installed since the list is empty).

Actual Results

The playbook fails as follows:

 Module failed with exception: list index out of range

A workaround is to add the following:

- name: install snap packages
  community.general.snap:
    name: "{{ snap_packages }}"
  when: snap_packages.0 is defined

However this isn't necessary for other similar commands like ansible.builtin.apt and worked on older versions of community.general, so this seems like a bug.

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) labels Aug 15, 2023
@felixfontein
Copy link
Collaborator

CC @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 module module plugins plugin (any type)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants