Hi, ansible newbie here. been trying to install Ansible from local machine to EC . . .

ELMER IBAYAN:
hi, ansible newbie here. been trying to install Ansible from local machine to EC2 server. I couldn’t seem to get the playbook working. The apache part is working. Below is what I have so far. I keep getting this error during the Install Ansible step : [Errno 14] HTTP Error 404 - Not Found

- hosts: web_servers
remote_user: ec2-user
  tasks:
  - name: Install Apache2
    yum:
      name: httpd
      state: present

  - name: Start Apache2 and enable it on boot
      service:
        name: httpd
        state: started
        enabled: yes

  - name: Enable EPEL Repository on CentOS 7
      ansible.builtin.yum_repository:
        name: epel
        description: EPEL YUM repo
        baseurl: <https://download.fedoraproject.org/pub/epel/$releasever/$basearch/>

  - name: Install Ansible
      yum:
        name: ansible
        state: present

Al West:
The error is in setting the EPEL release. ~Those parameters beginning with $ mean nothing to ansible.~ Either hard code them or lookup the variables in ansible facts. The code you have is the same as the example in the ansible documentation. Ensure you have the latest version of ansible installed (through pip3).

ELMER IBAYAN:
Thanks, do you mean latest ansible installation on mac? I am using : ansible [core 2.15.1]. I set the baseurl: <https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm> but still the same issue on the epel-release step that I have:

    - name: Install EPEL repository
      yum:
        name: epel-release
        state: present

ELMER IBAYAN:
here’s the actual error:

FAILED! =&gt; {"changed": false, "msg": "Failure talking to yum: failure: repodata/repomd.xml from epel: [Errno 256] No more mirrors to try.\n<https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm/repodata/repomd.xml>: [Errno 14] HTTPS Error 404 - Not Found"}

Al West:
You’re receiving a 404 error because the URL you’re using in the baseurl attribute is not correct. You are pointing it to a specific RPM file, but baseurl should point to a YUM repository, which is a URL that hosts a collection of RPM packages, not a specific RPM package itself.

To install the EPEL repository, it is generally better to install the epel-release package which configures the repository for you:

- name: Install EPEL repository
  yum:
    name: epel-release
    state: present

ELMER IBAYAN:
alright, thanks. i found out that the issue is due to security group settings of my ec2. it’s working now… but will take note on the epel-release config you mentioned…