yum_repository module (has anyone thought of doing it...)

Hi All

I just noticed that I wanted to run ‘yum-conf-manager’ to add http://ftp1.scientificlinux.org/linux/scientific/6.4/x86_64/addons/mock-sl6-config/ to my SL machines for testing and realised that there is probably a need for creating a yum_repository module that takes a url and adds/removes it on the managed machine (state=present,absent). Other useful things might include states=enabled,disabled as well to toggle the availability of packages from different repos. I’m not sure if you would want to have functionality like supporting adding/removing repo files though as you could just do that with the stock copy/template modules.

Jimmy.

But a yum repository is just a simple file. Why not just use copy or
template or even get_url?

-sv

I concur, I would almost always just template these into yum.repos.d

This might not be helpful for you, but can you get an RPM for the repo? I just do this:



<br> - name: ensure PGDG Yum repo is installed<br><br>

|

  • |


    <br> shell: rpm -Uvh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm <br><br>

    |


    <br> creates=/etc/yum.repos.d/pgdg-92-centos.repo<br><br>

    |

(being a little lazy there with using shell instead of command and the useless flags to rpm, but who cares)

not a bad trick!

Can you add this to https://coderwall.com/p/t/ansible ?

Sure thing, I’ll get around to it tomorrow.

Cheers

Here we go: https://coderwall.com/p/bqgksg?i=16&p=2&q=sort%3Ascore+desc&t[]=ansible

I’m so bad at formatting.

Indent each line by four characters for the markdown to kick in.

I agree it’s a little weird :slight_smile:

That’s what I’m doing now. What’s funny is the preview looks fine, but the end result has wierd formatting. Meh,

I think it seems to want to wrap text too early in some cases.

I’m not sure why when we all have wide screen monitors coderwall wants to wrap things around 40 characters :slight_smile:

This might not be helpful for you, but can you get an RPM for the repo? I
just do this:

  - name: ensure PGDG Yum repo is installed

      shell: rpm -Uvh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
             creates=/etc/yum.repos.d/pgdg-92-centos.repo

This is exactly how I do it, but I'd still like to be able to disable
the repo.

e.g. when I want repoforge added, I have a role:

repoforge/vars/main.yml:

Haven’t used it myself, but have you looked at the ini_file module?

Haven't used it myself, but have you looked at the
ini_file<http://ansible.cc/docs/modules.html?highlight=replace#ini-file&gt;module?

Hmm, no I didn't even think to consider it. But reading the doco, it
may do exactly what I want. Thanks! :slight_smile:

Chris

I just happen to have created a yum_repository plugin [1] for Ansible based on my own needs. In the environment I work with we use a continuous integration system to generate new rpm repositories throughout the day, so it’s helpful to deal with them this way. It also greatly simplifies the code for making changes to existing repositories.

For instance, if I wanted to disable my Centos updates repository, I could use something like:

ansible all -m yum_repository -a “id=updates state=disabled”

I haven’t submitted a pull request yet, but will if other people find it useful.

[1] https://github.com/mspaulding06/ansible/blob/yum_repository_plugin/library/packaging/yum_repository

Hi,

The yum_repository module sounds exactly what I’ve been looking for. Unfortunately the url doesn’t work and I’m unable to find it anywhere. Is it still available somewhere?

Thanks in advance,

/Johan

Is this still not implemented to ansible core?

2014년 2월 13일 목요일 오후 10시 22분 54초 UTC+9, Johan Söderberg 님의 말:

Check out the module index, there is http://docs.ansible.com/ansible/yumrepo_module.html. This is an extras module.

New link is here http://docs.ansible.com/ansible/yum_repository_module.html