0

I have been trying to write a playbook that adds the EPEL repo to the list of repos available.

The playbook I have is:

- hosts: all

  # define variables.
  vars:
    epelReleaseMajorVersion: 7
    epelReleaseMinorVersion: 8

  tasks:
    - name: add epel repo
      yum-repository:
        name: add epel repo
        description: EPEL YUM repo
        baseurl:  http://dl.fedoraproject.org/pub/epel/$epelReleaseMajorVersion/x86_64/e/epel-release-$epelReleaseMajorVersion-$epelReleaseMinorVersion.noarch.rpm
        tags: addEpelRepo

I am trying to run this playbook like so:
ansible-playbook -v -i "localhost," -c local serverSetup.yml

and get the following error:

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/root/ansible/playbooks/serverSetup.yml': line 21, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
    - name: add epel repo
      ^ here

My questions:
1. Am I using the variables epelReleaseMajorVersion etc. correctly?
2. How do I solve for this error? I have been taking a look at the docs but there do not seem to be many examples.

4

Refer to https://docs.ansible.com/ansible/yum_repository_module.html

Your code should be

- hosts: all

  # define variables.
  vars:
    epelReleaseMajorVersion: 7
    epelReleaseMinorVersion: 8

  tasks:
    - name: add epel repo
      yum_repository:
        name: epel_repo
        description: EPEL YUM repo
        baseurl:  http://dl.fedoraproject.org/pub/epel/{{epelReleaseMajorVersion}}/x86_64/

So you misspelled the name of the module. Baseurl was wrong. Variable reference was wrong. And yum_repository ansible module does not have any parameter called tags

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.