Bug 2022065 - ansible modules don't work correctly when a HTTP→HTTPS redirect occurs
Summary: ansible modules don't work correctly when a HTTP→HTTPS redirect occurs
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible Collection
Version: 6.9.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: 6.12.0
Assignee: satellite6-bugs
QA Contact: Griffin Sullivan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-10 16:57 UTC by moritz.stern
Modified: 2022-11-16 13:33 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-16 13:32:59 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github theforeman foreman-ansible-modules pull 1328 0 None open Warn if the user tries to use a plain HTTP server URL 2021-12-13 09:36:19 UTC
Red Hat Issue Tracker SAT-13528 0 None None None 2022-10-21 15:30:48 UTC
Red Hat Product Errata RHSA-2022:8506 0 None None None 2022-11-16 13:33:13 UTC

Description moritz.stern 2021-11-10 16:57:33 UTC
Description of problem:
Not possible to create content credential through redhat.satellite.content_credentials-role

How reproducible:
Use collection to create a content credential

Steps to Reproduce:
1. Try to execute the example on https://console.redhat.com/ansible/automation-hub/repo/published/redhat/satellite/content/role/content_credentials

Actual results:
{
    "ansible_loop_var": "item",
    "_ansible_item_label": {
        "content": "test",
        "name": "test",
        "content_type": "gpg_key"
    },
    "item": {
        "content": "test",
        "name": "test",
        "content_type": "gpg_key"
    },
    "error": {
        "displayMessage": "One of parameters [ organization_id ] required but not specified.",
        "errors": [
            "One of parameters [ organization_id ] required but not specified."
        ]
    },
    "msg": "Error while performing create on content_credentials: 404 Client Error: Not Found for url: https://satellite.MYORG.com/katello/api/content_credentials",
    "changed": false,
    "invocation": {
        "module_args": {
            "username": "MYUSER",
            "name": "test",
            "server_url": "http://satellite.MYORG.com",
            "content": "test",
            "state": "present",
            "content_type": "gpg_key",
            "organization": "MYORGANIZATION",
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "validate_certs": false
        }
    },
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "_ansible_no_log": false
}

Expected results:
A Content Credential is created


Additional info:

Comment 1 Evgeni Golov 2021-11-11 07:34:54 UTC
Hi,

- what version of Satellite are you running this against?
- can you share the playbook you used? the error "One of parameters [ organization_id ] required but not specified." suggests that for some reason no Organization was passed (which is weird)

Comment 2 moritz.stern 2021-11-11 07:51:31 UTC
Hi Evgeni,

- Satellite version is 6.9.0
- sure:

- name: CreateContentCredential
  hosts: localhost
  become: no
  gather_facts: no

  roles:
    - role: redhat.satellite.content_credentials
      vars:
        satellite_username: "{{ API_USERNAME }}"
        satellite_password: "{{ API_PASSWORD }}"
        satellite_server_url: "http://satellite.MYORG.com"
        satellite_organization: "{{ satellite_org }}"
        satellite_content_credentials:
          - name: "{{ satellite_product_key }}"
            content_type: gpg_key
            content: "{{ satellite_product_gpg_key_plain }}"

Environment variables:

satellite_org: MYORGANIZATION
satellite_product_gpg_key_plain: test
satellite_product_key: test 

Kind regards,
Moritz

Comment 3 Evgeni Golov 2021-11-11 07:54:15 UTC
Thanks!

The playbook looks good to me. I'll spin up a 6.9 and see if I can reproduce this.

Is your setup really a 6.9.0, nothing newer like 6.9.6/6.9.7? (Not that I think there were any bugfixes in that area, but still, 6.9.0 is rather old ;))

Comment 4 Evgeni Golov 2021-11-11 07:58:06 UTC
Ha!

Is that really 'http' in your server_url? Not httpS?

Comment 5 moritz.stern 2021-11-12 07:22:02 UTC
Yes, 6.9.0

Tried both http and https

Comment 6 Evgeni Golov 2021-11-12 08:02:13 UTC
So I can reproduce this when I set
  satellite_server_url: "http://satellite.MYORG.com"

But it works fine when I do
  satellite_server_url: "httpS://satellite.MYORG.com"

The reason behind this is: when you issue a HTTP request, Satellite does a redirect to HTTPS, and when the redirect is followed, the POST request data is not sent along.

Not sure we can nicely catch this, but I'll see what others think.

Comment 7 moritz.stern 2021-11-12 11:55:03 UTC
Oh my. Didn't push the commit with the change to https. It's working. Sorry for the noise.

Comment 8 Evgeni Golov 2021-11-12 12:25:57 UTC
Haha, no worries.

I'll leave the BZ open, and will try to improve the error reporting :)

Comment 11 Griffin Sullivan 2022-07-25 15:34:41 UTC
Verified in 6.12 snap 3

New warning and failure messages shown when running playbooks with satellite server url starting with or without ["http", "https"].

Steps to Reproduce:
1) Create a playbook using satellite_server_url with "http://"
2) Run playbook
3) Remove "http://" from satellite_server_url in playbook
4) Run playbook

Expected Results:
Step 2 results with a warning stating "[WARNING]: You have configured a plain HTTP server URL. All communication will happen unencrypted."
Step 4 results with a failure stating "The server URL needs to be either HTTPS or HTTP!"

Actual Results:
Step 2 results with a warning stating "[WARNING]: You have configured a plain HTTP server URL. All communication will happen unencrypted."
Step 4 results with a failure stating "The server URL needs to be either HTTPS or HTTP!"

Comment 15 errata-xmlrpc 2022-11-16 13:32:59 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.12 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-2022:8506


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