Centos – Add extra module to ansible

ansibleautomationcentosyum

I have installed ansible to make automation deploy my system and i need some extra module to work with it. I downloaded module yumrepo.py on ansible github and add it to my library directory. But when i run, it show error ERROR: yumrepo is not a legal parameter of an Ansible Play. Here is my configuration in file ansible.cfg.

inventory      = /etc/ansible/hosts
library        = /etc/ansible/module/
remote_tmp     = $HOME/.ansible/tmp

and my playbook

---
- name: Add multiple repositories into the same file (1/2)
  yumrepo:
    name: epel
    description: EPEL YUM repo
    file: external_repos
    baseurl: http://download.fedoraproject.org/pub/epel/$releasever/$basearch/
    gpgcheck: no

Hope anybody help me. Thank so much

Best Answer

Which repository did you download yumrepo.py from?

What you should probably be using instead is the ansible-yumrepo role : https://github.com/picotrading/ansible-yumrepo (See here for more about roles)

You can install this in a roles directory which can be in the same directory as your playbook. I found I needed to rename the role from ansible-yumrepo to yumrepo locally when I cloned the repository from github.

$ git clone https://github.com/picotrading/ansible-yumrepo.git roles/yumrepo

Then the following playbook can be used as a starting point for what you want to do:

- hosts: all
  roles:
    - role: yumrepo
      yumrepo_repos:
        myrepo1:
          name: epel
          description: EPEL YUM repo
          file: external_repos
          baseurl: http://download.fedoraproject.org/pub/epel/$releasever/$basearch/
          gpgcheck: no