Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36497 - Allow unsetting GPG and SSL keys #10593

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Jun 9, 2023

What are the changes introduced in this pull request?

Without allow_nil: true API clients don't know they can update this parameter to nil to unset it again.

Considerations taken when implementing this change?

I want a working API :)

What are the testing steps for this pull request?

Using FAM, run the following playbook:

- name: issue 36497
  hosts: localhost
  become: no
  gather_facts: no
  tasks:
    - name: "create key"
      theforeman.foreman.content_credential:
        username: "admin"
        password: "changeme"
        server_url: "https://foreman.example.com/"
        validate_certs: false
        name: "RPM-GPG-KEY-my-repo"
        content_type: gpg_key
        organization: "Default Organization"
        content: "lol test"
    - name: product with key
      theforeman.foreman.product:
        username: "admin"
        password: "changeme"
        server_url: "https://foreman.example.com/"
        validate_certs: false
        name: "lol prod"
        organization: "Default Organization"
        gpg_key: "RPM-GPG-KEY-my-repo"
    - name: product without key
      theforeman.foreman.product:
        username: "admin"
        password: "changeme"
        server_url: "https://foreman.example.com/"
        validate_certs: false
        name: "lol prod"
        organization: "Default Organization"
        gpg_key: ""

Without the patch, the execution will fail with:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error while performing update on products: gpg_key_id can't be None"}

@theforeman-bot
Copy link

Issues: #36497

@evgeni evgeni changed the title Fixes #36497 - Allow unsetting GPG and SSK keys from a product Fixes #36497 - Allow unsetting GPG and SSL keys from a product Jun 9, 2023
@evgeni evgeni changed the title Fixes #36497 - Allow unsetting GPG and SSL keys from a product Fixes #36497 - Allow unsetting GPG and SSL keys Jun 9, 2023
@evgeni
Copy link
Member Author

evgeni commented Jun 9, 2023

[test katello]

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

vagrant@centos8-katello-devel-stable ~]$ ansible-playbook test_playbook.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [issue 36497] ****************************************************************************************************************************************************************

TASK [create key] *****************************************************************************************************************************************************************
ok: [localhost]

TASK [product with key] ***********************************************************************************************************************************************************
ok: [localhost]

TASK [product without key] ********************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error while performing update on products: gpg_key_id can't be None"}

PLAY RECAP ************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

After:

[vagrant@centos8-katello-devel-stable ~]$ ansible-playbook test_playbook.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

PLAY [issue 36497] ****************************************************************************************************************************************************************

TASK [create key] *****************************************************************************************************************************************************************
ok: [localhost]

TASK [product with key] ***********************************************************************************************************************************************************
ok: [localhost]

TASK [product without key] ********************************************************************************************************************************************************
changed: [localhost]

PLAY RECAP ************************************************************************************************************************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

thanks @evgeni! ACK 👍

@jeremylenz jeremylenz merged commit 5dc7382 into Katello:master Jun 9, 2023
5 checks passed
@evgeni evgeni deleted the i36497 branch June 11, 2023 10:03
wbclark pushed a commit to wbclark/katello that referenced this pull request Sep 7, 2023
wbclark pushed a commit that referenced this pull request Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants