Search code examples
ansibleyumepel

yum_repository module fails properly insert *repo configuration file


there, I am having an issue if anybody had encountered and solved it, please share your knowledge.


Machine: CentOS Linux release 7.6.1810 (Core) NAME="CentOS Linux"

epel.yml

 - name: Add repository
   yum_repository:
     name: epel
     description: epel-repo
     baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/

ansible-playbook epel.yml (I have removed not necessary part of the epel.yml)

Above, code when run successfully enters epel.repo in /etc/yum.repos.d/ folder. However, when I try to install any package it gives me en error referring "Failed to connect. Network is unreachable"

I have checked #cat /etc/yum.repos.d/epel.repo

baseurl=https://download.fedoraproject.org/pub/epel/// I searched for where $releasever adn $basearch variables come from? Not very concrete answers around. Please help.


Solution

  • It seems like yum couldn't determine $releasever and $basearch. Check this post for the possible reasons why this wasn't possible.

    To workaround the problem, you could try using the yum module instead:

    - name: install the latest version of epel
      yum:
        name: epel-release
        state: latest
    

    Or install it directly from the rpm package:

    - name: install from url
      yum:
        name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
        state: present