From 8038e6ef9e7165d158ffa30776d4be8b1cf2fd39 Mon Sep 17 00:00:00 2001 From: Kevin Tibi Date: Thu, 5 Apr 2018 12:16:18 +0200 Subject: [PATCH] Add support for custom yum repositories Change-Id: I0370663b2d8ee7526dd2ba64266d6702800dfb76 Story: 2001775 Task: 12481 --- ansible/roles/yum/defaults/main.yml | 11 ++++++++++ ansible/roles/yum/tasks/custom_repo.yml | 28 +++++++++++++++++++++++++ ansible/roles/yum/tasks/main.yml | 2 ++ doc/source/release-notes.rst | 3 +++ etc/kayobe/yum.yml | 11 ++++++++++ 5 files changed, 55 insertions(+) create mode 100644 ansible/roles/yum/tasks/custom_repo.yml diff --git a/ansible/roles/yum/defaults/main.yml b/ansible/roles/yum/defaults/main.yml index e9e4c8611..2556ada91 100644 --- a/ansible/roles/yum/defaults/main.yml +++ b/ansible/roles/yum/defaults/main.yml @@ -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: {} diff --git a/ansible/roles/yum/tasks/custom_repo.yml b/ansible/roles/yum/tasks/custom_repo.yml new file mode 100644 index 000000000..72034be0c --- /dev/null +++ b/ansible/roles/yum/tasks/custom_repo.yml @@ -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' diff --git a/ansible/roles/yum/tasks/main.yml b/ansible/roles/yum/tasks/main.yml index 6f96f909c..07f63a3e0 100644 --- a/ansible/roles/yum/tasks/main.yml +++ b/ansible/roles/yum/tasks/main.yml @@ -4,3 +4,5 @@ when: - ansible_os_family == "RedHat" - yum_use_local_mirror + +- include: custom_repo.yml diff --git a/doc/source/release-notes.rst b/doc/source/release-notes.rst index c6a50c52f..57004dc6b 100644 --- a/doc/source/release-notes.rst +++ b/doc/source/release-notes.rst @@ -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 ------------- diff --git a/etc/kayobe/yum.yml b/etc/kayobe/yum.yml index 5d0af6d47..66832d3c0 100644 --- a/etc/kayobe/yum.yml +++ b/etc/kayobe/yum.yml @@ -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.