Skip to content

webarch-coop/ansible-role-alternatives

Repository files navigation

Webarchitects Debian alternatives Ansible Role

pipeline status

An Ansible role to manage Debian alternatives, see the update-alternatives man page.

This role requires jc version 1.18.8 or greater to generate JSON from the output of update-alternatives --query.

yq can be used to convert JSON to YAML for the generation of the configuration, for example this command:

jc -p update-alternatives --query editor | yq -P

Will generate a block of YAML that can be edited as necessary and used with this role as a item in the alternatives_update array.

The Ansible managed alternatives are listed in the /etc/ansible/alternatives file, one per line, and the /etc/ansible/facts.d/update_alternatives.fact script generates JSON facts for each listed alternative.

If the supplied configuration matches and facts then all the update tasks will be skipped.

If a state variable is added into the settings array then this can be set to absent to remove alternatives, it defaults to present, see the defaults/main.yml for an example.

There are tree default variables:

Variable name Default value Comment
alternatives false Run the tasks in this role, set to true for tasks to be run
alternative_facts true Install and run the update_alternatives.fact script in /etc/ansible/facts.d
alternatives_update undefined Define this variable with list of alternatives that match the jc -p update-alternatives --query output

Note that this role doesn't use the Ansible alternatives module because that currently has no support for "slaves".

This role can also be used with the localhost repo to install alternatives locally.

Repository

The primary URL of this repo is https://git.coop/webarch/alternatives however it is also mirrored to GitHub and available via Ansible Galaxy.

If you use this role please use a tagged release, see the release notes.

Copyright

Copyright 2022-2025 Chris Croome, <[email protected]>.

This role is released under the same terms as Ansible itself, the GNU GPLv3.

About

An Ansible role to manage Debian and Ubuntu alternatives

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages