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 2224122 - Cannot unset GPG keys from repositories
Summary: Cannot unset GPG keys from repositories
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible Collection
Version: 6.14.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.15.0
Assignee: Evgeni Golov
QA Contact: Griffin Sullivan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-19 21:05 UTC by Ian Ballou
Modified: 2024-04-23 17:11 UTC (History)
4 users (show)

Fixed In Version: ansible-collection-redhat-satellite-3.13.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-04-23 17:11:46 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github theforeman foreman-ansible-modules pull 1649 0 None open don't fail when searching for a content credential for a repository 2023-07-25 07:17:38 UTC
Red Hat Issue Tracker SAT-19138 0 None None None 2023-07-25 12:20:11 UTC
Red Hat Product Errata RHSA-2024:2010 0 None None None 2024-04-23 17:11:47 UTC

Description Ian Ballou 2023-07-19 21:05:59 UTC
Description of problem:
Continuation of https://bugzilla.redhat.com/show_bug.cgi?id=2213777.

That BZ fixed unsetting products' GPG keys. Now, there is an issue with unsetting repositories' GPG keys.

The following error occurs:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to lookup scope ['organization'] while searching for content_credentials."}

Version-Release number of selected component (if applicable):
Satellite 6.14.0

How reproducible:
100%

Steps to Reproduce:
Run the following playbook:

[root@sat-6-14-qa-rhel8 ~]# cat playbook-bz-2213777.yml 
- name: issue 36497
  hosts: localhost
  become: no
  gather_facts: no
  tasks:
    - name: "create key"
      redhat.satellite.content_credential:
        username: "admin"
        password: "changeme"
        server_url: "https://sat-6-14-qa-rhel8.example.com/"
        validate_certs: false
        name: "RPM-GPG-KEY-my-repo"
        content_type: gpg_key
        organization: "Default Organization"
        content: "test"
    - name: product with key
      redhat.satellite.product:
        username: "admin"
        password: "changeme"
        server_url: "https://sat-6-14-qa-rhel8.example.com/"
        validate_certs: false
        name: "prod"
        organization: "Default Organization"
        gpg_key: "RPM-GPG-KEY-my-repo"
    - name: product without key
      redhat.satellite.product:
        username: "admin"
        password: "changeme"
        server_url: "https://sat-6-14-qa-rhel8.example.com/"
        validate_certs: false
        name: "prod"
        organization: "Default Organization"
        gpg_key: ""
    - name: repo with key
      redhat.satellite.repository:
        username: "admin"
        password: "changeme"
        server_url: "https://sat-6-14-qa-rhel8.example.com/"
        validate_certs: false
        name: "repo"
        organization: "Default Organization"
        product: "prod"
        content_type: "yum"
        gpg_key: "RPM-GPG-KEY-my-repo"
    - name: repo without key
      redhat.satellite.repository:
        username: "admin"
        password: "changeme"
        server_url: "https://sat-6-14-qa-rhel8.example.com/"
        validate_certs: false
        name: "repo"
        organization: "Default Organization"
        product: "prod"
        content_type: "yum"
        gpg_key: ""

Actual results:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to lookup scope ['organization'] while searching for content_credentials."}

Expected results:
GPG key on the repository at the end is unset.

Additional info:
Copy-pasted from https://bugzilla.redhat.com/show_bug.cgi?id=2213777:

The issue I found on repositories appears to  be in foreman ansible modules itself:


831  ->	    def lookup_entity(self, key, params=None):
832  	        if key not in self.foreman_params:
833  	            return None
834  	
835  	        entity_spec = self.foreman_spec[key]
836  	        if _is_resolved(entity_spec, self.foreman_params[key]):
(Epdb) key
'organization'

(Epdb) self.foreman_params['organization']
*** KeyError: 'organization'

(Epdb) self.foreman_params['entity']['organization']
{'name': 'Default Organization', 'label': 'Default_Organization', 'id': 1}

The organization is in the body of the request from Katello:

2023-07-19T20:41:07 [D|app|42104fc2] With body:   {"relative_path":"Default_Organization/Library/custom/prod/repo","promoted":false,"content_view_version_id":1,"library_instance_id":null,"last_contents_changed":"2023-07-19 19:08:38 UTC","organization_id":1,"organization":{"name":"Default Organization","label":"Default_Organization","id":1},...

It looks like the foreman ansible modules might be filtering out the organization somehow.  The organization is in self.foreman_params['entity'] but not self.foreman_params, which is causing it to not be found.

Comment 4 Evgeni Golov 2023-08-23 07:47:17 UTC
I've prepared packaging at https://gitlab.cee.redhat.com/satellite/satellite-packaging/-/merge_requests/7424

Comment 5 Brad Buckingham 2023-10-30 11:29:29 UTC
Bulk setting Target Milestone = 6.15.0 where sat-6.15.0+ is set.

Comment 6 Griffin Sullivan 2024-01-02 14:40:15 UTC
Verified on 6.15.0 snap 3 with collection version 3.14.0

Users can set and unset GPG keys for both products and repositories.

Comment 9 errata-xmlrpc 2024-04-23 17:11:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.15.0 release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2024:2010


Note You need to log in before you can comment on or make changes to this bug.