From: David Galloway Date: Mon, 16 May 2022 15:41:11 +0000 (-0400) Subject: testnode: Work around rare CentOS infra mirror mismatch X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F678%2Fhead;p=ceph-cm-ansible.git testnode: Work around rare CentOS infra mirror mismatch Signed-off-by: David Galloway --- diff --git a/roles/testnode/tasks/yum/baseurls_not_mirrorlists.yml b/roles/testnode/tasks/yum/baseurls_not_mirrorlists.yml new file mode 100644 index 00000000..5292b568 --- /dev/null +++ b/roles/testnode/tasks/yum/baseurls_not_mirrorlists.yml @@ -0,0 +1,30 @@ +--- +- name: dnf check-update to see if mirrorlists are working + command: dnf check-update + register: mirrorlist_check + ignore_errors: true + +# Default to false +- set_fact: + use_baseurls: false + +- set_fact: + use_baseurls: true + when: '"all mirrors were already tried" in mirrorlist_check.stderr' + +- name: Get list of repo files we need to use baseurls for + shell: "grep -l '^mirrorlist' *.repo | grep -v epel | cut -d '.' -f1" + args: + chdir: /etc/yum.repos.d + register: repo_files_with_mirrorlists + when: use_baseurls|bool is true + +- name: Comment mirrorlist parameter in each repo + shell: "sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/{{ item }}.repo" + with_items: "{{ repo_files_with_mirrorlists.stdout_lines }}" + when: use_baseurls|bool is true + +- name: Use a baseurl instead + shell: "echo 'baseurl=http://packages.oit.ncsu.edu/centos/{{ ansible_distribution_major_version }}{{ dash_stream }}/{% if item == \"CentOS-Extras\" %}extras{% else %}{{ item | regex_replace('CentOS-','') }}{% endif %}/{{ ansible_architecture }}/os/' >> /etc/yum.repos.d/{{ item }}.repo" + with_items: "{{ repo_files_with_mirrorlists.stdout_lines }}" + when: use_baseurls|bool is true diff --git a/roles/testnode/tasks/yum/repos.yml b/roles/testnode/tasks/yum/repos.yml index 278d8d7f..7a99ada4 100644 --- a/roles/testnode/tasks/yum/repos.yml +++ b/roles/testnode/tasks/yum/repos.yml @@ -31,6 +31,11 @@ with_dict: "{{ yum_repos|default({}) | combine(additional_yum_repos|default({}), recursive=True) }}" when: (yum_repos.keys() | length > 0) or (additional_yum_repos.keys() | length > 0) +# Occasionally when the yum repo mirrors get updated, we get 404s when using mirrorlist +# but not when using baseurls. No idea why. +- include_tasks: yum/baseurls_not_mirrorlists.yml + when: ansible_distribution == "CentOS" + - name: Enable copr repos command: "dnf -y copr enable {{ item }}" with_items: "{{ copr_repos }}"