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

brocade_facts: https broken in release 2.0.0 #170

Open
mamoep opened this issue Feb 7, 2025 · 2 comments
Open

brocade_facts: https broken in release 2.0.0 #170

mamoep opened this issue Feb 7, 2025 · 2 comments

Comments

@mamoep
Copy link

mamoep commented Feb 7, 2025

Using brocade_facts module and setting https: True doesn't work correctly in release 2.0.0. Connection is still done via http. Setting https: self is doing https connection.

  - name: gather Brocade facts
    brocade.fos.brocade_facts:
      credential:
        fos_ip_addr: "{{ hostname }}"
        fos_user_name: "{{ username }}"
        fos_password: "{{ password }}"
        https: True
      vfid: -1
      gather_subset:
        - brocade_security_user_config
        - brocade_security_ldap_role_map

Result was:

FAILED - RETRYING: [localhost]: gather Brocade facts (5 retries left).Result was: {
    "POST_resp_code": 403,
    "POST_resp_data": {
        "errors": {
            "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-restconf",
            "error": {
                "error-app-tag": "Error",
                "error-info": {
                    "error-code": "58",
                    "error-module": "rest"
                },
                "error-message": "HTTP interface is disabled. Please use HTTPS.",
                "error-tag": "operation-failed",
                "error-type": "application"
            }
        }
    },
    "POST_resp_reason": "Forbidden",
    "POST_url": "http://switchname.local/rest/login",
    "attempts": 1,
    "changed": false,
    "invocation": {
        "module_args": {
            "credential": {
                "fos_ip_addr": "switchname.local",
                "fos_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "fos_user_name": "username",
                "https": "True",
                "ssh_hostkeymust": null
            },
            "gather_subset": [
                "brocade_security_user_config",
                "brocade_security_ldap_role_map"
            ],
            "throttle": null,
            "timeout": null,
            "vfid": -1
        }
    },
    "msg": "POST failed",
    "retries": 6
}

Ansible Environment

$ ansible --version
ansible [core 2.16.3]
  config file = /home/username/ansible/ansible.cfg
  configured module search path = ['/home/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/username/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.8 (main, Dec  9 2024, 15:25:01) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.12)
  jinja version = 3.1.2
  libyaml = True

Redefining the argument_spec in brocade_facts

https=dict(required=True, type='str'),

to https=dict(required=True, type='bool') makes it work again. I doubt this parameter was ever tested correctly. What's so hard in using real certificates?

@prasad-valmeti-broadcom
Copy link
Collaborator

I have merged this change into the external develop branch. You can take this fix and let us know if this resolves the issue that you are seeing:
diff --git a/utils/brocade_url.py b/utils/brocade_url.py
index 8e00e6a..49f6050 100644
--- a/utils/brocade_url.py
+++ b/utils/brocade_url.py
@@ -25,6 +25,7 @@ VF_ID = "?vf-id="
HTTP = "http://"
HTTPS = "https://"
SELF_SIGNED = "self"
+HTTPS_ENABLED = "true"

ERROR_GENERIC = -1
@@ -37,6 +38,8 @@ def full_url_get(is_https, fos_ip_addr, path):
return HTTPS + fos_ip_addr + str_to_yang(path), True
else:
return HTTP + fos_ip_addr + str_to_yang(path), False

  • elif is_https.lower() == HTTPS_ENABLED:
  •    return HTTPS + fos_ip_addr + str_to_yang(path), True
    
    elif is_https.lower() == SELF_SIGNED:
    return HTTPS + fos_ip_addr + str_to_yang(path), False
    else:

From the beginning, we considered fos_https a string with three values: True, False, and Self. But somehow, it got exposed with the credentials marked https as the string type.
We will incorporate the changes in the next patch release.

@mamoep
Copy link
Author

mamoep commented Feb 11, 2025

The proposed fix is working. I hope for a quick production release in Galaxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants