Bug 2224122 - Cannot unset GPG keys from repositories
Summary: Cannot unset GPG keys from repositories
Keywords:
Status: POST
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible Collection
Version: 6.14.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Evgeni Golov
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-19 21:05 UTC by Ian Ballou
Modified: 2023-08-15 06:08 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
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

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.


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