cans.package-source
cans.package-source
This is a simple tool to add or remove software sources and their GPG keys for your Linux distribution.
Adding or Removing Sources
To add or remove a source, describe it this way:
- repo: "name of the repository" (required)
- codename: "
" (optional) - key_id: "
" (optional) - key_server: "
" (optional) - key_url: "
" (optional) - keyring: "
" (optional) - update_cache: <yes|no> (optional, default is no)
This tool will first add the sources and then remove them. You can specify the order in your playbook, which will be followed when adding or removing sources.
If you leave out optional values, they will be ignored. The only value that is needed is repo, which must be a valid description of an APT repository.
If you want to add a key for a source, you must provide a key_id to avoid adding an unwanted key to APT. You will also need to specify either key_url or key_server to retrieve the key.
Changing the default value of update_cache is usually not recommended, as it can slow down your playbook. It's better to update the cache after adding the package sources to validate them.
Requirements
This tool requires Ansible's modules for managing package sources:
- For Debian-based distributions, see apt_repository and apt_key.
Role Variables
All variables begin with the prefix pkgsources
:
- pkgsource_present: List of sources to make sure are available (default:
[]
). - pkgsource_absent: List of sources to make sure are not available (default:
[]
).
Deprecated Variables
- pkgsource_user: This variable is no longer used as you can set it when you import the role or at the play level (default:
ansible_user_id
).
Dependencies
There are no external dependencies for this tool.
Example Playbook
Here’s an example playbook that adds two new sources and removes one. It also installs a GPG key for one of the sources. At the end, it forces a cache update to validate the configuration.
- hosts: servers
roles:
- role: "cans.package-source"
pkgsource_present:
- repo: "deb http://ftp.fr.debian.org/debian/ stable-backports main"
- repo: "deb https://toolbelt.heroku.com/ubuntu/ ./"
key_id: C927EBE00F1B0520
key_url: "https://toolbelt.herokuapp.com/apt/release.key"
pkgsource_absent:
- "deb http://ftp.fr.debian.org/debian/ wheezy main"
update_cache: yes
License
This software is free to use and modify under the terms of the GNU General Public License version 2.
Author Information
Copyright © 2017-2018 by Nicolas CANIART.
Role to manage Distribution Package Sources and their Encryption Keys
ansible-galaxy install cans.package-source