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 module breaks alternatives with families on CentOS-based systems #3751

Closed
1 task done
boricj opened this issue Nov 18, 2021 · 5 comments
Closed
1 task done
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) system

Comments

@boricj
Copy link

boricj commented Nov 18, 2021

Summary

The alternatives module does not handle alternatives with families on CentOS-based systems. The module appears to fail to properly parse the output of update-alternatives --display <item>, confusing it into running update-alternatives --install which destroys the package's original alternatives configuration. This happens for example with Java alternatives, where tools such as keytool cannot be invoked after configuring with this module.

Debian-based systems do not seem to support alternative families and do not exhibit this problem.

Note: while this bug has been encountered on an obsolete version of Ansible, the bug does currently exist on the main branch, as this regex cannot handle the family format:

alternative_regex = re.compile(r'^(\/.*)\s-\spriority', re.MULTILINE)

Issue Type

Bug Report

Component Name

alternatives

Ansible Version

$ ansible --version
ansible 2.9.27
  config file = /home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg
  configured module search path = ['/home/boric/Documents/cms5g/tools4-5g/ansible/library']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Aug 12 2021, 07:06:15) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

Note: as noted above, bug exists on the main branch too.

Community.general Version

$ ansible-galaxy collection list community.general
usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...
ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: 'list' (choose from 'init', 'build', 'publish', 'install')

Note: as noted above, bug exists on the main branch too.

Configuration

$ ansible-config dump --only-changed
ANSIBLE_PIPELINING(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=60s -o ServerAliveInterval=240
DEFAULT_FILTER_PLUGIN_PATH(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['/home/boric/Documents/cms5g/tools4-5g/ansible/filter_plugins']
DEFAULT_HOST_LIST(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['/home/boric/Documents/cms5g/tools4-5g/ansible/environments/ci5g/ci5g.yaml']
DEFAULT_LOOKUP_PLUGIN_PATH(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['/home/boric/Documents/cms5g/tools4-5g/ansible/lookup_plugins', '/home/boric/ansible/tools4-5g/ansible/lookup_plugins']
DEFAULT_MODULE_PATH(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['/home/boric/Documents/cms5g/tools4-5g/ansible/library']
DEFAULT_MODULE_UTILS_PATH(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['/home/boric/Documents/cms5g/tools4-5g/ansible/library/module_utils']
DEFAULT_ROLES_PATH(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['/home/boric/.ansible/roles', '/etc/ansible/roles', '/home/boric/Documents/cms5g/tools4-5g/ansible/roles', '/home/boric/ansible/tools4ct/roles']
HOST_KEY_CHECKING(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = False
INVENTORY_ENABLED(/home/boric/Documents/cms5g/tools4-5g/ansible/ansible.cfg) = ['yaml']

OS / Environment

CentOS 8

Steps to Reproduce

On a CentOS 8 environnment, install two JDKs (yum install java-1.8.0-openjdk-headless.x86_64 java-11-openjdk-headless.x86_64) and run a playbook containing the following task, replacing path with the actual package version installed:

  tasks:
    - name: Configure alternatives
      alternatives:
        name: "java"
        path: "/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/java"
        link: "/usr/bin/java"

Expected Results

Java alternative links (both main and slaves) points to Java 11, as if the following command was executed:

# update-alternatives --set java /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/java
# update-alternatives --display java
java - status is manual.
 link currently points to /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800312
 slave alt-java: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/alt-java
 slave jjs: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/jjs
 slave keytool: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/keytool
 slave orbd: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/orbd
 slave pack200: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/pack200
 slave policytool: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/policytool
 slave rmid: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/rmid
 slave rmiregistry: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/rmiregistry
 slave servertool: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/servertool
 slave tnameserv: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/tnameserv
 slave unpack200: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/unpack200
 slave jre: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre
 slave alt-java.1.gz: /usr/share/man/man1/alt-java-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave java.1.gz: /usr/share/man/man1/java-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave jjs.1.gz: /usr/share/man/man1/jjs-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave keytool.1.gz: /usr/share/man/man1/keytool-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave orbd.1.gz: /usr/share/man/man1/orbd-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave pack200.1.gz: /usr/share/man/man1/pack200-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave policytool.1.gz: /usr/share/man/man1/policytool-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave rmid.1.gz: /usr/share/man/man1/rmid-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave rmiregistry.1.gz: /usr/share/man/man1/rmiregistry-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave servertool.1.gz: /usr/share/man/man1/servertool-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave tnameserv.1.gz: /usr/share/man/man1/tnameserv-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave unpack200.1.gz: /usr/share/man/man1/unpack200-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/java - family java-11-openjdk.x86_64 priority 1
 slave alt-java: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/alt-java
 slave jjs: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/jjs
 slave keytool: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/keytool
 slave orbd: (null)
 slave pack200: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/pack200
 slave policytool: (null)
 slave rmid: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/rmid
 slave rmiregistry: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/rmiregistry
 slave servertool: (null)
 slave tnameserv: (null)
 slave unpack200: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/unpack200
 slave jre: /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64
 slave alt-java.1.gz: /usr/share/man/man1/alt-java-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave java.1.gz: /usr/share/man/man1/java-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave jjs.1.gz: /usr/share/man/man1/jjs-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave keytool.1.gz: /usr/share/man/man1/keytool-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave orbd.1.gz: (null)
 slave pack200.1.gz: /usr/share/man/man1/pack200-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave policytool.1.gz: (null)
 slave rmid.1.gz: /usr/share/man/man1/rmid-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave rmiregistry.1.gz: /usr/share/man/man1/rmiregistry-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
 slave servertool.1.gz: (null)
 slave tnameserv.1.gz: (null)
 slave unpack200.1.gz: /usr/share/man/man1/unpack200-java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64.1.gz
Current `best' version is /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/java.

Actual Results

Java main alternative link points to Java 11, but slave links, family and original priority information are lost:

# update-alternatives --display java
java - status is manual.
 link currently points to /usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800312
 slave alt-java: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/alt-java
 slave jjs: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/jjs
 slave keytool: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/keytool
 slave orbd: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/orbd
 slave pack200: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/pack200
 slave policytool: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/policytool
 slave rmid: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/rmid
 slave rmiregistry: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/rmiregistry
 slave servertool: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/servertool
 slave tnameserv: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/tnameserv
 slave unpack200: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/unpack200
 slave jre: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre
 slave alt-java.1.gz: /usr/share/man/man1/alt-java-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave java.1.gz: /usr/share/man/man1/java-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave jjs.1.gz: /usr/share/man/man1/jjs-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave keytool.1.gz: /usr/share/man/man1/keytool-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave orbd.1.gz: /usr/share/man/man1/orbd-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave pack200.1.gz: /usr/share/man/man1/pack200-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave policytool.1.gz: /usr/share/man/man1/policytool-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave rmid.1.gz: /usr/share/man/man1/rmid-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave rmiregistry.1.gz: /usr/share/man/man1/rmiregistry-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave servertool.1.gz: /usr/share/man/man1/servertool-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave tnameserv.1.gz: /usr/share/man/man1/tnameserv-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
 slave unpack200.1.gz: /usr/share/man/man1/unpack200-java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64.1.gz
/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-3.el8_5.x86_64/bin/java - priority 50
 slave alt-java: (null)
 slave jjs: (null)
 slave keytool: (null)
 slave orbd: (null)
 slave pack200: (null)
 slave policytool: (null)
 slave rmid: (null)
 slave rmiregistry: (null)
 slave servertool: (null)
 slave tnameserv: (null)
 slave unpack200: (null)
 slave jre: (null)
 slave alt-java.1.gz: (null)
 slave java.1.gz: (null)
 slave jjs.1.gz: (null)
 slave keytool.1.gz: (null)
 slave orbd.1.gz: (null)
 slave pack200.1.gz: (null)
 slave policytool.1.gz: (null)
 slave rmid.1.gz: (null)
 slave rmiregistry.1.gz: (null)
 slave servertool.1.gz: (null)
 slave tnameserv.1.gz: (null)
 slave unpack200.1.gz: (null)
Current `best' version is /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-2.el8_5.x86_64/jre/bin/java.

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 Nov 18, 2021
@Akasurde
Copy link
Member

@boricj Could you please check if #3976 fixes this issue? Thanks in advance.

@Akasurde Akasurde added the needs_info This issue requires further information. Please answer any outstanding questions label Jan 25, 2022
@boricj
Copy link
Author

boricj commented Jan 25, 2022

@Akasurde As noted in #3976, I no longer have the setup to test the fix against, but I believe it would fix the issue.

@ansibullbot ansibullbot removed the needs_info This issue requires further information. Please answer any outstanding questions label Jan 25, 2022
@felixfontein
Copy link
Collaborator

Let's close this issue for now. If it turns out this is still an issue, either someone can create a new one, or we can re-open this one.

Thanks everyone!

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

No branches or pull requests

4 participants