vagrant upが「One of the configured repositories failed」エラーで失敗するときの対処方法

概要

Vagrantで管理するCentOS7を $ vagrant up で起動しようとしたときに以下のようなエラーが出た場合の対処方法です。

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
    default: 29324 (guest) => 29324 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
[default] GuestAdditions versions on your host (6.1.26) and guest (6.0.10) do not match.
読み込んだプラグイン:fastestmirror


 One of the configured repositories failed (不明),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
Unmounting Virtualbox Guest Additions ISO from: /mnt
umount: /mnt: not mounted
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 6.0.10
    default: VirtualBox Version: 6.1
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

umount /mnt

Stdout from the command:



Stderr from the command:

umount: /mnt: not mounted

環境

  • ホストマシン
    • macOS Big Sur 11.5.2
    • VirtualBox 6.1.26 r145957 (Qt5.6.3)
    • Vagrant 2.2.18
  • ゲストマシン
    • CentOS Linux release 7.1.1503 (Core)

手順

  • 仮想マシンにSSH接続する

    vagrant ssh
    

    vagrant up でエラーが出ていても、仮想マシン自体は起動しているのでSSHはできる。

  • yumのミラーレポジトリを無効化する

    • /etc/yum.repos.d/epel.repo を以下のように編集する

      /etc/yum.repos.d/epel.repo
      [epel]
      name=Extra Packages for Enterprise Linux 7 - $basearch
      - #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
      + baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
      - mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
      + #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
      failovermethod=priority
      enabled=1
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
      
      [epel-debuginfo]
      name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
      - #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
      + baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
      - #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
      + mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
      failovermethod=priority
      enabled=0
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
      gpgcheck=1
      
      [epel-source]
      name=Extra Packages for Enterprise Linux 7 - $basearch - Source
      - #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
      + baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
      - #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
      + mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
      failovermethod=priority
      enabled=0
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
      gpgcheck=1
      
  • 仮想マシンを再起動する

    vagrant reload
    

背景

開発しているシステムのローカル開発環境はVagrantで管理していて、仮想マシンの構成を変更したタイミングでBoxを作っていますが、久々に過去のBoxから新たにマシンを起動したところ上述のエラーが発生してしまいました。

感想

Vagrantでのローカル開発環境は、今回のようなケースや、macOSのアップデート時にうまく動かなくなることが多いです。また、Boxの容量も1〜2GBになるので、他の開発者に渡すにもコストがかかっています。そろそろDocker化したいと思っています。

参考にさせていただいたサイト

© 2021 itotetsu.work / This site uses Google Analytics.