Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1907978

Summary: Error on enable repo using repository_set when prior configured through UI
Product: Red Hat Satellite Reporter: Steffen Froemer <sfroemer>
Component: Ansible CollectionAssignee: Evgeni Golov <egolov>
Status: CLOSED CURRENTRELEASE QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: egolov, jsherril, ldelouw, zhunting
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-04-09 05:33:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1919321    
Bug Blocks:    

Description Steffen Froemer 2020-12-15 15:50:46 UTC
Description of problem:
Using 'repository_set' from redhat.satellite to enable Red Hat Repositories will fail, when the repo was enabled and in use through UI before.


Version-Release number of selected component (if applicable):
ansible-collection-redhat-satellite-1.3.0-1.el7sat.noarch

How reproducible:
Seen it several times, but unable to reproduce.

1) Add RH repo in UI
2) Add RH repo in UI and synchronized
3) Add RH repo in UI, synchronized and Published a CV

In all three scenarios, I was able to configure the repository using the ansible role.

Steps to Reproduce:
1. unclear
2.
3.

Actual results:
It's failing with error

TASK [Enable Red Hat Kickstart repositories] *********************************************************************$
ok: [sat6.example.com] => (item={u'repos': [{u'basearch': u'x86_64', u'releasever': u'7.7'}, {u'basearch'$ u'x86_64', u'releasever': u'7.8'}], u'label': u'rhel-7-server-kickstart'})
failed: [sat6.example.com] (item={u'repos': [{u'basearch': u'x86_64', u'releasever': u'6.10'}], u'label': u'rhel-6-server-kickstart'}) => {"ansible_loop_var": "item", "changed": false, "item": {"label": "rhel-6-server-ki$kstart", "repos": [{"basearch": "x86_64", "releasever": "6.10"}]}, "msg": "Desired repositories are not available $n the repository set label: rhel-6-server-kickstart.\nSearched: {'repositories': [{'basearch': 'x86_64', 'releasev$r': '6.10'}], 'label': 'rhel-6-server-kickstart'}\nFound: []\nAvailable: []"}

Remove through UI and enable it again using ansible, everything is fine.

Expected results:
It should work out of the box.

Additional info:


---
- hosts: localhost
  gather_facts: false

  vars_files:
    - group_vars/all.yml

  vars:
    redhat_kickstart_repos:
    - label: "rhel-7-server-kickstart"
      repos:
      - { releasever: "7.7", basearch: "x86_64" }
      - { releasever: "7.8", basearch: "x86_64" }

    - label: "rhel-6-server-kickstart"
      repos:
      - { releasever: "6.10", basearch: "x86_64" }

  collections:
    - redhat.satellite

  tasks:

  - name: "Enable Red Hat Kickstart repositories"
    repository_set:
      username: "{{ satellite_username }}"
      password: "{{ satellite_password }}"
      server_url: "{{ satellite_url }}"
      organization: "{{ satellite_organization }}"
      validate_certs: "{{ validate_certs }}"
      label: "{{ item.label }}"
      state: enabled
      repositories: "{{ item.repos }}"
    loop: "{{ redhat_kickstart_repos }}"
    tags:
      - enable_redhat_kickstart_repos
      - repos

Comment 6 Evgeni Golov 2021-01-21 14:52:21 UTC
So, my memory says this is (most probably) related to https://projects.theforeman.org/issues/28644

Some of our CDN repositories use "basearch", some "releasever" and some both (and some none of these) as place-holders in the URL.
To find the right repository using ansible, you need to provide values for that, and the module then fetches all "enable-able" repos from a set and matches based on your input.
Now the bug I linked above resulted in some repos that e.g. don't have the "basearch" place-holder be enabled WITH the placeholder if done in the UI -- and then ansible can't find that the set is enabled and then things go south (it tries to enable it and fails)

Comment 7 Steffen Froemer 2021-01-21 14:56:10 UTC
Thanks, that helps me to investigate further. As soon I have more clarification on this, I will provide feedback.

Comment 8 Evgeni Golov 2021-01-22 12:00:29 UTC
Hey,

can I please get the output of the following playbook in an affected environment? It should only dump the EL6 kickstarts

---
- hosts: localhost
  gather_facts: false
  vars:
    server_url: https://foreman.example.com
    username: admin
    password: changeme
    validate_certs: False
    organization: "Default Organization"
    search: label=rhel-6-server-kickstart
  tasks:
  - name: "Search for possible repository sets of a product"
    theforeman.foreman.resource_info:
      username: "{{ username }}"
      password: "{{ password }}"
      server_url: "{{ server_url }}"
      validate_certs: "{{ validate_certs }}"
      organization: "{{ organization }}"
      resource: repository_sets
      search: "{{ search }}"
    register: data
  - name: "Output found repository sets, see the contentUrl section for possible repository substitutions"
    debug:
      var: data
  - name: "get available"
    uri:
      url: "{{ server_url }}/katello/api/products/{{ item['product']['id'] }}/repository_sets/{{ item['id'] }}/available_repositories"
      url_username: "{{ username }}"
      url_password: "{{ password }}"
      validate_certs: "{{ validate_certs }}"
      force_basic_auth: True
    register: available
    loop: "{{ data.resources }}"
  - name: debug
    debug:
      var: item
    loop: "{{ available.results | map(attribute='json') | list }}"

Comment 9 Evgeni Golov 2021-01-22 12:23:20 UTC
obviously with redhat.satellite.resource_info if you use the satellite collection :)

Comment 10 Evgeni Golov 2021-01-22 15:33:58 UTC
I've linked a BZ that should clean up part of this bug on the Katello side, but I don't see how that *exact* issue should affect 6.10 kickstarts, as those DO have both basearch and releasever substitutions.

The output of the playbook would be greatly appreciated.

Comment 11 Evgeni Golov 2021-01-22 15:45:30 UTC
to clarify: this doesn't feel the same as the linked BZ finds the repo, tries to enable it and fails as it's already enabled.

here it's not finding the repo in the first place.

Comment 13 Evgeni Golov 2021-01-29 06:56:54 UTC
Can you please re-run the playbook with "timeout: 300" set on the "uri" task? So:

 - name: "get available"
    uri:
      url: "{{ server_url }}/katello/api/products/{{ item['product']['id'] }}/repository_sets/{{ item['id'] }}/available_repositories"
      url_username: "{{ username }}"
      url_password: "{{ password }}"
      validate_certs: "{{ validate_certs }}"
      force_basic_auth: True
      timeout: 300
    register: available
    loop: "{{ data.resources }}"

Comment 14 Evgeni Golov 2021-02-01 07:39:28 UTC
intentation error…

  - name: "get available"
    uri:
      url: "{{ server_url }}/katello/api/products/{{ item['product']['id'] }}/repository_sets/{{ item['id'] }}/available_repositories"
      url_username: "{{ username }}"
      url_password: "{{ password }}"
      validate_certs: "{{ validate_certs }}"
      force_basic_auth: True
      timeout: 300
    register: available
    loop: "{{ data.resources }}"

Comment 19 Evgeni Golov 2021-02-16 13:42:12 UTC
After talking to Justin, this might be a case of https://bugzilla.redhat.com/show_bug.cgi?id=1899313 and we should re-try on a newer Satellite.

Comment 20 Justin Sherrill 2021-02-16 14:02:31 UTC
Specifically 6.8.2 or newer

Comment 21 Evgeni Golov 2021-04-09 05:33:47 UTC
> "after upgrade to version 6.8.5 everything is working fine."

closing as "CURRENTRELEASE" then, thanks!