4

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

Ha Phuoc
  • 53
  • 2
  • 5
  • Which version of ansible did you install? – Michael Hampton Dec 31 '15 at 14:59
  • 1
    Is that your entire playbook? If so then it's not formed quite right. You need to specify the hosts to run against at the very least. Take a look at the sample playbooks [here](http://docs.ansible.com/ansible/playbooks_intro.html) for the correct format & pay particular attention to 'hosts', and 'tasks'. – Bruce P Jan 05 '16 at 12:59

4 Answers4

1

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
Richard Corfield
  • 3,779
  • 1
  • 15
  • 11
1

yumrepo is provided by ansible-extras The problem is most likely that a version of this module that contains yumrepo has not yet been released. If you check the extras directory in your ansible installation you can verify this. Mine is at:

/usr/local/lib/python2.7/site-packages/ansible/modules/extras/packaging/os/
ls -ltr 

You will see that there is no yumrepo.py file. One solution is therefore as someone has already suggested clone the yumrepo role into your roles directory instead of trying to use the module. If you're absolutely set on using this module you can copy this yumrepo.py module from the github repo into a directory say ~/unreleased-ansible-extras and add it to your ANSIBLE_LIBRARY environment variable as per http://docs.ansible.com/ansible/developing_modules.html

e.g.

export ANSIBLE_LIBRARY=$ANSIBLE_LIBRARY:~/unreleased-ansible-extras

but it's probably better you just use the role and wait for the next release for the time being.

1

Place the module file in playbooks/library it will automatically pick it up, do not change your default ANSIBLE_LIBRARY vars, just use what it install with yum/pip. Also, don't put them in a subdirectory.

You'll have something like...

hosts/hostfile
hosts/group_vars/all/custom_vars.yml
playbooks/library/plugin.py
playbooks/library/plugin2.py
playbooks/roles
playbooks/my_playbook.yml
Jacob Evans
  • 7,886
  • 3
  • 29
  • 57
0

I found my extras packages in /usr/local/lib/python2.7/dist-packages/ansible/modules/extras/ and I've installed Ansible via pip, but still yumrepo is not present.