Skip to content

Instantly share code, notes, and snippets.

@minusdavid
minusdavid / main.yml
Last active July 23, 2016 14:53
Custom Ansible module to parse redhat.repo (or any ConfigParser compatible file) and return the file as facts (as per the advice in http://docs.ansible.com/ansible/developing_modules.html), so that they can be used to run subscription-manager in an idempotent manner
---
- site_facts: src=/etc/yum.repos.d/redhat.repo
- name: Enable Red Hat repositories via subscription-manager
command: subscription-manager repos --enable {{ item }}
when: site_facts[item]['enabled'] is defined and site_facts[item]['enabled'] != "1"
with_items:
- rhel-6-server-optional-rpms
- rhel-6-server-extras-rpms