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

Alternatives subcommand is missing link if not passed explicitly #4804

Closed
1 task done
twecker137 opened this issue Jun 8, 2022 · 6 comments · Fixed by #4836
Closed
1 task done

Alternatives subcommand is missing link if not passed explicitly #4804

twecker137 opened this issue Jun 8, 2022 · 6 comments · Fixed by #4836
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) system

Comments

@twecker137
Copy link

twecker137 commented Jun 8, 2022

Summary

When I try to use the alternatives module from collection version 5.1.0, it seems that the new subcommands feature is not behaving correctly on Red Hat systems, when subcommands are already in place.
Please see the details below.

Issue Type

Bug Report

Component Name

alternatives

Ansible Version

ansible --version
ansible [core 2.12.4]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.5 (default, Nov 23 2021, 15:27:38) [GCC 9.3.0]
  jinja version = 3.1.1
  libyaml = True

Community.general Version

ansible-galaxy collection list community.general

# /usr/local/lib/python3.9/dist-packages/ansible_collections
Collection        Version
----------------- -------
community.general 4.7.0  

# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 5.1.0

Configuration

ansible-config dump --only-changed
ANSIBLE_FORCE_COLOR(/azp/_work/6/s/lz/project/ansible/ansible.cfg) = True
DEFAULT_TRANSPORT(/azp/_work/6/s/lz/project/ansible/ansible.cfg) = ssh
INVENTORY_ENABLED(/azp/_work/6/s/lz/project/ansible/ansible.cfg) = ['host_list', 'script', 'auto', 'yaml', 'ini', 'azure_rm']

OS / Environment

Target system: Red Hat Enterprise Linux release 8.6 (Ootpa)
Ansible runner: ubuntu:20.04 / Container instance in Azure

Steps to Reproduce

- name: Add python to alternatives system
  community.general.alternatives:
    name: python
    path: /usr/bin/python3
    link: /usr/bin/python

Have python3 installed:

alternatives --display python
python - status is manual.
 link currently points to /usr/bin/python3
/usr/libexec/no-python - priority 404
 slave unversioned-python: (null)
 slave unversioned-python-man: /usr/share/man/man1/unversioned-python.1.gz
/usr/bin/python3 - priority 300
 slave unversioned-python: /usr/bin/python3
 slave unversioned-python-man: /usr/share/man/man1/python3.1.gz
Current `best' version is /usr/libexec/no-python.

Expected Results

I expected it would set python3 as the default python executable and any existing subcommand will be considered accordingly.

Actual Results

Since collection version 5.1.0 the Ansible task will fail, as slave parameter are missing the slave-link argument:

fatal: [server]: FAILED! => {"changed": false, "cmd": "/sbin/update-alternatives --install /usr/bin/python python /usr/bin/python3 50 --slave unversioned-python /usr/bin/python3 --slave unversioned-python-man /usr/share/man/man1/python3.1.gz", "msg": "", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "alternatives version 1.19.1 - Copyright (C) 2001 Red Hat, Inc.\nThis may be freely redistributed under the terms of the GNU Public License.\n\nusage: alternatives --install <link> <name> <path> <priority>\n                    [--initscript <service>]\n                    [--family <family>]\n                    [--slave <slave_link> <slave_name> <slave_path>]*\n       alternatives --remove <name> <path>\n       alternatives --auto <name>\n       alternatives --config <name>\n       alternatives --display <name>\n       alternatives --set <name> <path>\n       alternatives --list\n       alternatives --remove-all <name>\n       alternatives --add-slave <name> <path> <slave_link> <slave_name> <slave_path>\n       alternatives --remove-slave <name> <path> <slave_name>\n\ncommon options: --verbose --test --help --usage --version --keep-missing --keep-foreign\n                --altdir <directory> --admindir <directory>\n", "stdout_lines": ["alternatives version 1.19.1 - Copyright (C) 2001 Red Hat, Inc.", "This may be freely redistributed under the terms of the GNU Public License.", "", "usage: alternatives --install <link> <name> <path> <priority>", "                    [--initscript <service>]", "                    [--family <family>]", "                    [--slave <slave_link> <slave_name> <slave_path>]*", "       alternatives --remove <name> <path>", "       alternatives --auto <name>", "       alternatives --config <name>", "       alternatives --display <name>", "       alternatives --set <name> <path>", "       alternatives --list", "       alternatives --remove-all <name>", "       alternatives --add-slave <name> <path> <slave_link> <slave_name> <slave_path>", "       alternatives --remove-slave <name> <path> <slave_name>", "", "common options: --verbose --test --help --usage --version --keep-missing --keep-foreign", "                --altdir <directory> --admindir <directory>"]}

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

cc @mulby
click here for bot help

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) system labels Jun 8, 2022
@felixfontein
Copy link
Collaborator

CC @jiuka

jiuka added a commit to jiuka/community.general that referenced this issue Jun 8, 2022
If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug ansible-collections#4803 and ansible-collections#4804
@felixfontein
Copy link
Collaborator

resolved_by_pr #4810

@felixfontein
Copy link
Collaborator

Unfortunately that PR does not fix this issue, see #4810 (comment)

felixfontein added a commit that referenced this issue Jun 13, 2022
* alternatives: Fix bug with priority default

If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug #4803 and #4804

* Add changelog fragment.

* Distinguish None from 0.

* Address review comments.

* Update plugins/modules/system/alternatives.py

Co-authored-by: Pilou <pierre-louis@libregerbil.fr>

* Remove unrelated issues from changelog.

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Pilou <pierre-louis@libregerbil.fr>
patchback bot pushed a commit that referenced this issue Jun 13, 2022
* alternatives: Fix bug with priority default

If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug #4803 and #4804

* Add changelog fragment.

* Distinguish None from 0.

* Address review comments.

* Update plugins/modules/system/alternatives.py

Co-authored-by: Pilou <pierre-louis@libregerbil.fr>

* Remove unrelated issues from changelog.

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Pilou <pierre-louis@libregerbil.fr>
(cherry picked from commit 57e83ac)
felixfontein pushed a commit that referenced this issue Jun 13, 2022
* alternatives: Fix bug with priority default

If neigther the priority nor the subcommands where specified the module decided to update the priority with the default value anyway. This resulted in bug #4803 and #4804

* Add changelog fragment.

* Distinguish None from 0.

* Address review comments.

* Update plugins/modules/system/alternatives.py

Co-authored-by: Pilou <pierre-louis@libregerbil.fr>

* Remove unrelated issues from changelog.

Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Pilou <pierre-louis@libregerbil.fr>
(cherry picked from commit 57e83ac)

Co-authored-by: Marius Rieder <marius.rieder@durchmesser.ch>
@felixfontein
Copy link
Collaborator

resolved_by_pr #4836

This was referenced Nov 20, 2022
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) system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants