Failed to download metadata for repo ‘AppStream’ – Mirrorlist [CentOS]

I was trying to make Ansible work on my Ubuntu machine and as part of the exercise, I had to add a CentOS machine to the host file on Ubuntu. I have a CentOS 8 VM running so I thought it would be a quick one to add ansible over there and then come back to my Ubuntu machine to complete the rest of the task. Well, I was wrong and I got stuck installing Ansible package on my CentOS machine. After spending a good amount of my time going through threads and forums I finally found the issue.

These are the errors I was getting no matter what I try to install on my CentOS:

Fix:

CentOS Linux 8 have reached the End of Life (EOL) on Dec 31st, 2021. This means CentOS 8 will no longer receive development resources. If you need to update your CentOS 8 then you need to change the mirrors to vault.centos.org. Alternatively, you may want to upgrade to CentOS Stream.

Follow these steps to change the mirrors:

cd /etc/yum.repos.d/

sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-*

sed -i ‘s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g’ /etc/yum.repos.d/CentOS-*

yum update -y

I also managed to install Ansible

Advertisement

One thought on “Failed to download metadata for repo ‘AppStream’ – Mirrorlist [CentOS]

  1. Also, perhaps just use:
    sed -i.bak ‘s/^mirror/#mirror/;s/#baseurl/baseurl/;s/mirror.centos/vault.centos/’ CentOS-*.repo

    If you have multiple hosts chuck this into an Ansible playbook:


    – name: Resolve CentOS 8 repo issues
    hosts: “{{ nodes }}”
    tasks:
    – shell: sed -i.bak ‘s/^mirror/#mirror/;s/#baseurl/baseurl/;s/mirror.centos/vault.centos/’ /opt/yum.repos.d/CentOS-*.repo
    when:
    – ansible_distribution == ‘CentOS’
    – ansible_distribution_major_version == ‘8’

    I couldn’t figure out lineinfile/replace regex to run multiple changes through multiple files, probably some with_nested loop syntax required.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: