---
- block:
    - name: disable unneeded repos
      command: subscription-manager repos --disable='*'

    - name: ensure proper repos are assigned
      command: subscription-manager repos --enable={{ item }}
      with_items: "{{ gluster_repos }}"

    - name: check to see if rhui exists
      stat:
        path: /etc/yum.repos.d/redhat-rhui.repo
      register: rhui

    - name: check to see if rhui client exists
      stat:
        path: /etc/yum.repos.d/redhat-rhui-client-config.repo
      register: client

    - name: disable rhui repo
      replace:
        dest: /etc/yum.repos.d/redhat-rhui.repo
        regexp: 'enabled=1'
        replace: 'enabled=0'
      when: rhui.stat.exists

    - name: disable rhui client repos
      replace:
        dest: /etc/yum.repos.d/redhat-rhui-client-config.repo
        regexp: 'enabled=1'
        replace: 'enabled=0'
      when: client.stat.exists

  when: ansible_distribution == "RedHat"
