Add repos validations role.

This patch migrates the former validations/repos.yaml validation into
a role.

Change-Id: I10fbabf135908845d78eec64f780db04dffb42d1
Implements: blueprint validation-framework
This commit is contained in:
Jose Luis Franco Arza
2019-02-28 15:10:20 +01:00
committed by Gael Chamoulaud
parent 98d61e30a2
commit de9812bd81
5 changed files with 129 additions and 0 deletions

15
playbooks/repos.yaml Normal file
View File

@@ -0,0 +1,15 @@
---
- hosts: undercloud, overcloud
vars:
metadata:
name: Check correctness of current repositories
description: >
Detect whether the repositories listed in `yum repolist`
can be connected to and that there is at least one repo
configured.
Detect if there are any unwanted repositories (such as EPEL) enabled.
groups:
- pre-upgrade
roles:
- repos

41
roles/repos/README.md Normal file
View File

@@ -0,0 +1,41 @@
Repos
==============
An Ansible role to check the correctness of current repositories.
Requirements
------------
This role could be used before/after an Undercloud or an Overcloud has been
deployed.
Role Variables
--------------
- None
Dependencies
------------
No dependencies.
Example Playbook
----------------
- hosts: undercloud
roles:
- role: repos
- hosts: overcloud
roles:
- role: repos
License
-------
Apache
Author Information
------------------
Red Hat TripleO Validations Team

27
roles/repos/meta/main.yml Normal file
View File

@@ -0,0 +1,27 @@
galaxy_info:
author: TripleO Validations Team
company: Red Hat
license: Apache
min_ansible_version: 2.4
platforms:
- name: CentOS
versions:
- 7
- name: RHEL
versions:
- 7
categories:
- cloud
- baremetal
- system
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

View File

@@ -0,0 +1,35 @@
---
- name: List repositories
command: 'yum repolist -v'
args:
warn: no
changed_when: False
register: repositories
- name: Find repository URLs
shell: 'echo "{{ repositories.stdout }}" | grep Repo-baseurl | sed "s/Repo-baseurl.*\(http[^ ]*\).*/\1/g"'
register: repository_urls
changed_when: False
- name: Check if there is at least one repository baseurl
fail:
msg: No repository found in yum repolist
when: repository_urls.stdout_lines|length < 1
- name: Call repository URLs
uri:
url: "{{ item }}"
with_items: "{{ repository_urls.stdout_lines }}"
- name: Find repository IDs
changed_when: False
shell: 'echo "{{ repositories.stdout }}" | grep Repo-id | sed "s/Repo-id.*://" | tr -d " "'
register: repository_ids
- name: Check if there are any unwanted repositories enabled
fail:
msg: Found unwanted repository {{ item.0 }} enabled
when: item.0 == item.1
with_nested:
- [ 'epel/x86_64' ]
- "{{ repository_ids.stdout_lines }}"

11
roles/repos/vars/main.yml Normal file
View File

@@ -0,0 +1,11 @@
---
metadata:
name: Check correctness of current repositories
description: >
Detect whether the repositories listed in `yum repolist`
can be connected to and that there is at least one repo
configured.
Detect if there are any unwanted repositories (such as EPEL) enabled.
groups:
- pre-upgrade