diff --git a/releasenotes/notes/check-repo-availability-ef1bdd45586929f7.yaml b/releasenotes/notes/check-repo-availability-ef1bdd45586929f7.yaml new file mode 100644 index 000000000..b3e12a26e --- /dev/null +++ b/releasenotes/notes/check-repo-availability-ef1bdd45586929f7.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Adds a validation to the pre-upgrade group that checks if current + repositories can be connected to and if there is at least one repo + configured in yum repolist. diff --git a/validations/check-repo-availability.yaml b/validations/check-repo-availability.yaml new file mode 100644 index 000000000..d13f24d2d --- /dev/null +++ b/validations/check-repo-availability.yaml @@ -0,0 +1,23 @@ +--- +- hosts: undercloud, overcloud + vars: + metadata: + name: Check availability 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. + groups: + - pre-upgrade + tasks: + - name: Find repository URLs + shell: 'yum repolist -v | grep Repo-baseurl | sed "s/Repo-baseurl.*\(http[^ ]*\).*/\1/g"' + register: repository_urls + - 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