Skip to content

Alternatives subcommand is missing link if not passed explicitly #4804

@twecker137

Description

@twecker137

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions