---
- name: Register the host to Red Hat account
  include_tasks: register_cdn.yml
  # no need to register if machine already subscribed
  when: "cdn_args_file != ''"

# unregister repos and register back if no activation-key is used.
# if activation-key is used, the env will be automatically attached
# and subscribed to the repos assigned to the activation-key
- block:
    - name: unregister from all repos
      command: subscription-manager repos --disable=*
      failed_when: (unregister_repos.rc != 0 and "'*' does not match a valid repository ID." not in unregister_repos.stdout)
      register: unregister_repos
      become: true

    - name: register to openstack repos
      vars:
          repo_list: "{{ (subscriptions.common_8 if (install_version|openstack_release) >= 15 else subscriptions.common_7) + (subscriptions[install_version|openstack_release] if not cdn_skip_openstack_repos | default(false) else []) }}"
          modified_list: "{{ repo_list | map('regex_replace', '^(.*)$', '--enable=\\1') | join(' ') }}"
      command: "subscription-manager repos {{ modified_list }}"
      become: true
  # running also if subscriptions are defined to avoid job breakages.
  when: (cdn_args_file != '' and cdn_creds.activationkey is undefined) or (subscriptions is defined and subscriptions|length > 0 )

- name: refresh yum cache
  package:
      name: kernel
      state: present
      update_cache: yes
  become: true

- name: repolist
  command: "yum -v repolist --all"
  become: true

---
- name: Register the host to Red Hat account
  include_tasks: register_cdn.yml
  # no need to register if machine already subscribed
  when: "cdn_args_file != ''"

# unregister repos and register back if no activation-key is used.
# if activation-key is used, the env will be automatically attached
# and subscribed to the repos assigned to the activation-key
- block:
    - name: unregister from all repos
      command: subscription-manager repos --disable=*
      failed_when: (unregister_repos.rc != 0 and "'*' does not match a valid repository ID." not in unregister_repos.stdout)
      register: unregister_repos
      become: true

    - name: register to openstack repos
      vars:
          repo_list: "{{ (subscriptions.common_8 if (install_version|openstack_release) >= 15 else subscriptions.common_7) + (subscriptions[install_version|openstack_release] if not cdn_skip_openstack_repos | default(false) else []) }}"
          modified_list: "{{ repo_list | map('regex_replace', '^(.*)$', '--enable=\\1') | join(' ') }}"
      command: "subscription-manager repos {{ modified_list }}"
      become: true
  # running also if subscriptions are defined to avoid job breakages.
  when: (cdn_args_file != '' and cdn_creds.activationkey is undefined) or (subscriptions is defined and subscriptions|length > 0 )

- name: refresh yum cache
  package:
      name: kernel
      state: present
      update_cache: yes
  become: true

- name: repolist
  command: "yum -v repolist"
  become: true

Remove '--all' from 'yum repolist'
Remove '--all' from 'yum repolist'

--all doesn't work in RHEL7 so removing it.

RHOSINFRA-3467

Change-Id: I5f9b36e6cc7b380242bf99b7810998e430b6c0e6
