Ansible Role alternatives
This role manages symbolic links using the update-alternatives
tool. Useful when multiple programs are installed but provide similar functionality (for example, different editors or Python interpreters).
Hints:
The priority is simply an integer weight that the system uses when you’re in
auto
mode to choose which of several installed alternatives should be the current default.When you install multiple candidates for the same generic name (e.g.
python3
), and you’ve left the alternative inauto
mode, the one with the highest priority number will be selected.When priorities are equal, the system will pick the first one that was registered (but you should avoid duplicate priorities to prevent ambiguity).
Mandatory Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
List of alternatives to remove or to deploy. Subkeys:
|
|
Example:
alternatives__alternatives:
- link: '/usr/bin/python3'
name: 'python3'
path: '/usr/bin/python3.9'
priority: '100' # install python3.9 with higher priority
state: 'auto'
- link: '/usr/bin/python3'
name: 'python3'
path: '/usr/bin/python3.12'
priority: '10'
state: 'auto'
# => results in python3.9