Add support for custom yum repositories

Change-Id: I0370663b2d8ee7526dd2ba64266d6702800dfb76
Story: 2001775
Task: 12481
This commit is contained in:
Kevin Tibi 2018-04-05 12:16:18 +02:00 committed by Mark Goddard
parent 7bdee9a21c
commit 8038e6ef9e
5 changed files with 55 additions and 0 deletions

View File

@ -10,3 +10,14 @@ yum_centos_mirror_directory: 'centos'
yum_epel_mirror_host: 'download.fedoraproject.org'
# Mirror directory for Yum EPEL repos.
yum_epel_mirror_directory: 'pub/epel'
# A dict of custom repositories.
# You can see params on
# http://docs.ansible.com/ansible/latest/modules/yum_repository_module.html.
# For example:
# yum_custom_repos:
# reponame:
# baseurl: http://repo
# file: myrepo
# gpgkey: http://gpgkey
# gpgcheck: yes
yum_custom_repos: {}

View File

@ -0,0 +1,28 @@
---
- name: Install custom repositories
yum_repository:
name: "{{ item.key }}"
description: "{% if 'description' in item.value %}{{ item.value.description }}{% else %}{{ item.key }} repository{% endif %}"
baseurl: "{{ item.value.baseurl }}"
file: "{{ item.value.file | default(omit)}}"
gpgkey: "{{ item.value.gpgkey | default(omit)}}"
gpgcheck: "{{ item.value.gpgcheck | default(omit)}}"
cost: "{{ item.value.cost | default(omit)}}"
enabled: "{{ item.value.enabled | default(omit)}}"
gpgcakey: "{{ item.value.gpgcakey | default(omit)}}"
metadata_expire: "{{ item.value.metadata_expire | default(omit)}}"
mirrorlist: "{{ item.value.mirrorlist | default(omit)}}"
mirrorlist_expire: "{{ item.value.mirrorlist_expire | default(omit)}}"
priority: "{{ item.value.priority | default(omit)}}"
proxy: "{{ item.value.proxy | default(omit)}}"
proxy_password: "{{ item.value.proxy_password | default(omit)}}"
proxy_username: "{{ item.value.proxy_username | default(omit)}}"
repo_gpgcheck: "{{ item.value.repo_gpgcheck | default(omit)}}"
sslverify: "{{ item.value.sslverify | default(omit)}}"
with_dict: "{{ yum_custom_repos }}"
register: register_yum_command
retries: 3
delay: 10
until: "'failed' not in register_yum_command"
when: ansible_os_family == 'RedHat'

View File

@ -4,3 +4,5 @@
when:
- ansible_os_family == "RedHat"
- yum_use_local_mirror
- include: custom_repo.yml

View File

@ -8,6 +8,9 @@ In Development
Features
--------
* Adds support for configuration of custom repositories. ``yum_custom_repos``
should be a dict of repositories.
Upgrade Notes
-------------

View File

@ -10,6 +10,17 @@
#yum_epel_mirror_host: 'download.fedoraproject.org'
# Mirror directory for Yum EPEL repos.
#yum_epel_mirror_directory: 'pub/epel'
# A dict of custom repositories.
# You can see params on
# http://docs.ansible.com/ansible/latest/modules/yum_repository_module.html.
# For example:
# yum_custom_repos:
# reponame:
# baseurl: http://repo
# file: myrepo
# gpgkey: http://gpgkey
# gpgcheck: yes
#yum_custom_repos:
###############################################################################
# Dummy variable to allow Ansible to accept this file.