community.general.alternatives (8.5.0) — module

Manages alternative programs for common commands

Authors: Marius Rieder (@jiuka), David Wittman (@DavidWittman), Gabe Mulley (@mulby)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manages symbolic links using the 'update-alternatives' tool.

Useful when multiple programs are installed but provide similar functionality (e.g. different editors).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Correct java version selected
  community.general.alternatives:
    name: java
    path: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Alternatives link created
  community.general.alternatives:
    name: hadoop-conf
    link: /etc/hadoop/conf
    path: /etc/hadoop/conf.ansible
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Make java 32 bit an alternative with low priority
  community.general.alternatives:
    name: java
    path: /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
    priority: -10
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install Python 3.5 but do not select it
  community.general.alternatives:
    name: python
    path: /usr/bin/python3.5
    link: /usr/bin/python
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install Python 3.5 and reset selection to auto
  community.general.alternatives:
    name: python
    path: /usr/bin/python3.5
    link: /usr/bin/python
    state: auto
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: keytool is a subcommand of java
  community.general.alternatives:
    name: java
    link: /usr/bin/java
    path: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
    subcommands:
      - name: keytool
        link: /usr/bin/keytool
        path: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/keytool

Inputs

    
link:
    description:
    - The path to the symbolic link that should point to the real executable.
    - This option is always required on RHEL-based distributions. On Debian-based distributions
      this option is required when the alternative O(name) is unknown to the system.
    type: path

name:
    description:
    - The generic name of the link.
    required: true
    type: str

path:
    description:
    - The path to the real executable that the link should point to.
    required: true
    type: path

state:
    choices:
    - present
    - selected
    - auto
    - absent
    default: selected
    description:
    - V(present) - install the alternative (if not already installed), but do not set
      it as the currently selected alternative for the group.
    - V(selected) - install the alternative (if not already installed), and set it as
      the currently selected alternative for the group.
    - V(auto) - install the alternative (if not already installed), and set the group
      to auto mode. Added in community.general 5.1.0.
    - V(absent) - removes the alternative. Added in community.general 5.1.0.
    type: str
    version_added: 4.8.0
    version_added_collection: community.general

priority:
    description:
    - The priority of the alternative. If no priority is given for creation V(50) is used
      as a fallback.
    type: int

subcommands:
    aliases:
    - slaves
    description:
    - A list of subcommands.
    - Each subcommand needs a name, a link and a path parameter.
    - Subcommands are also named 'slaves' or 'followers', depending on the version of
      alternatives.
    elements: dict
    suboptions:
      link:
        description:
        - The path to the symbolic link that should point to the real subcommand executable.
        required: true
        type: path
      name:
        description:
        - The generic name of the subcommand.
        required: true
        type: str
      path:
        description:
        - The path to the real executable that the subcommand should point to.
        required: true
        type: path
    type: list
    version_added: 5.1.0
    version_added_collection: community.general