jfautley.yumreposd
yumreposd
This Ansible role helps set up Yum repository files, which are usually located in the directory /etc/yum.repos.d/
.
Every repository defined in the main Yum repository settings will be created as a separate file in the specified directory. The role also runs yum cache expire-metadata
to update the metadata if there are any changes to the configured repositories on the managed system.
Role Variables
yumreposd_repos
- This is a list of the repositories to be set up. See the 'Repo Hash Format' section below for details.yumreposd_delete_unmanaged
- This controls whether to delete repo files in the destination directory that were not created by this role. It defaults tofalse
.yumreposd_preserve
- Used with the above option; any items in this list will NOT be deleted by thedelete_unmanaged
task. Do not include the '.repo' file extension.yumreposd_destdir
- The folder where you want the Yum repo configuration files. It typically defaults to/etc/yum.repos.d/
.yumreposd_importgpgkeys
- Determines if the role will import the configured repo GPG keys (if available) into the RPM key database. It defaults totrue
.
Repo Hash Format
The repo settings are defined in a single list called yumrepos_repos
, formatted like this:
yumreposd_repos:
repo-id:
name: Descriptive Name
baseurl: http://yourserver.com/repos/repo-id
gpgkey: file:///etc/pki/rpm-gpg/YOURSITE-KEY
gpgcheck: 1
other_option: here
repo-id-2:
name: Another repo
... etc ...
Each entry under a repository is processed when generating the configuration file. You can specify any options supported in the Yum repo configuration. No syntax checking is done.
Example Playbook
- hosts: all
vars:
- yumreposd_repos:
base-os:
name: Base Operating System Packages Repo
baseurl: http://repos.yourdomain/repos/base-os/{{ ansible_architecture }}
gpgcheck: 1
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
custom:
name: My custom repo
baseurl: http://repos.yourdomain/repos/custom/
gpgcheck: 0
- yumreposd_delete_unmanaged: true
- yumreposd_preserve:
- epel
- epel-testing
roles:
- yumreposd
As shown in the example, including the configuration settings in your playbook can lead to a complex setup, so it is strongly recommended to keep them organized elsewhere for clarity.
License
MIT
Parts of this code are based on Jiri Tyr's Ansible Yumrepo role.
Author Information
Please report any issues through the GitHub Issue Tracker. Pull requests are welcomed.
- Jon Fautley
- Email: jon@dead.li
- GitHub:
- Twitter: @filace
Role to manage /etc/yum.repos.d/ on RHEL-like systems
ansible-galaxy install jfautley.yumreposd