0

I am trying to vagrant up my two VMs: one is Ubuntu and the other is CentOS. One is working fine and the other gives this error:

Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=vag error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=vag error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

I have tried the ping thing. Internet is coming through but I am not sure why it is happening. I am sharing my vagrantfile too for reference. I tried other solutions on StackOverflow and couldn't find a solution that worked.

Vagrant.configure("2") do |config|
 
    # Configuration for web01 VM
    config.vm.define "web01" do |web01|
      web01.vm.box = "ubuntu/bionic64"
      web01.vm.hostname = "web01"
      web01.vm.network "private_network", ip: "192.168.40.11"
      web01.vm.provider "virtualbox" do |vb|
          vb.memory = "1024"
          vb.cpus = 2
        end
      web01.vm.provision "shell", inline: <<-SHELL
        apt update
          apt install apache2 wget unzip -y
          systemctl start apache2
          systemctl enable apache2
          cd /tmp/
          wget https://www.tooplate.com/zip-templates/2119_gymso_fitness.zip
          unzip -o 2119_gymso_fitness.zip
          cp -r 2119_gymso_fitness/* /var/www/html/
          systemctl restart apache2
      SHELL
    end
  
    # Configuration for db01 VM
    config.vm.define "db01" do |db01|
      db01.vm.box = "centos/7"
      db01.vm.hostname = "db01"
      db01.vm.network "private_network", ip: "192.168.40.12"
      db01.vm.provider "virtualbox" do |vb|
        vb.memory = "1024"
        vb.cpus = 2
     end
  
      # Provisioning with a shell script
      db01.vm.provision "shell", inline: <<-SHELL
        # Update package list and install necessary software 
        yum install -y mariadb-server -y
        systemctl start mariadb
        systemctl start mariadb
        systemctl enable mariadb
  
        mysql -u root -e 'CREATE DATABASE wordpress;'
        mysql -u root -e 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON wordpress.* TO wordpress@localhost IDENTIFIED BY "admin123";'
        mysql -u root -e 'FLUSH PRIVILEGES;'
      SHELL
    end
  end

1 Answer 1

0

CentOS 7 reached end of life (EOL) at the end of June and as a result of that mirrorlist.centos.org no longer works. If you need to keep using CentOS 7 (which I would not recommend) you need to switch to archived repositories at vault.centos.org by changing your .repo files in /etc/yum.repos.d from

mirrorlist=http://mirrorlist.centos.org...

to

baseurl=http://vault.centos.org...

running following commands before trying to install mariadb-server in your provision step should do the trick:

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-*

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.