brocade / ansible

55 stars 33 forks source link

FOS 9.1.X Compatibility #101

Open atroyblack opened 2 years ago

atroyblack commented 2 years ago

Having issues performing one of our playbooks which runs the three below tasks -

---
# This playbook will apply zoning for any switch supplied from inventory 
- hosts: all
  gather_facts: False
  collections:
    - brocade.fos

  vars:
    credential:
      fos_ip_addr: "{{ fos_ip_addr }}"
      fos_user_name: "{{ fos_user_name }}"
      fos_password: "{{ fos_password }}"
      https: "{{ https }}"
  vars_files:
    - "inventories/group_vars/{{datacenter}}.yml"

  tasks:

  - name: Create Aliases
    brocade_zoning_alias:
      credential: "{{credential}}"
      vfid: "{{vfid}}"
      aliases: "{{aliases}}"

  - name: Create Zones
    brocade_zoning_zone:
      credential: "{{credential}}"
      vfid: "{{vfid}}"
      zones: "{{zones}}"

  - name: Create Configs
    brocade_zoning_cfg:
      credential: "{{credential}}"
      vfid: "{{vfid}}"
      cfgs: "{{cfgs}}"
      active_cfg: "{{cfgs[0].name}}"

The error we're getting is in relation to a GET request of the effective-configuration -

❯ https --auth $stor_user:$stor_pass --verify false GET https://<SWITCH_NAME>/rest/running/zoning/effective-configuration --body
<?xml version="1.0" ?>
<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
  <error>
    <error-type>application</error-type>
    <error-tag>unknown-element</error-tag>
    <error-app-tag>Error</error-app-tag>
    <error-message>Invalid REST URI</error-message>
    <error-info>
      <error-code>5</error-code>
      <error-module>rest</error-module>
    </error-info>
  </error>
</errors>

It seems like in FOS 9.X the URI changed from - <base_uri>/running/zoning/effective-configuration to <base_uri>/running/brocade-zone/effective-configuration

This is noted in https://docs.broadcom.com/doc/FOS-90x-REST-API-RM page 583 Looks like https://github.com/brocade/ansible/blob/2fee2195fef52f8351bd3b33a71a598651f7bd87/utils/brocade_zoning.py#L21 still references the prior URI path. Our environment is current sitting on a mix of FOS 8.2.X and FOS 9.1.X We've leverage Brocade's FOS Ansible Galaxy. With the current version in our production environment running on collection 1.0.23 which is ~2 years old. We did some testing with the latest Brocade FOS Ansible collection 1.3.0 but ran into the same issue.

I can't say with confidence that this specific URI path issue would be the only issue we're going to see as the playbook isn't able to get passed this first error. But it does look like brocade_zoning.py is referenced in all three tasks of the specific playbook above - https://github.com/brocade/ansible/blob/2fee2195fef52f8351bd3b33a71a598651f7bd87/library/brocade_zoning_alias.py#L166 https://github.com/brocade/ansible/blob/2fee2195fef52f8351bd3b33a71a598651f7bd87/library/brocade_zoning_zone.py#L167 https://github.com/brocade/ansible/blob/2fee2195fef52f8351bd3b33a71a598651f7bd87/library/brocade_zoning_cfg.py#L169

We did test one of our FOS 8.2.X switches and both <base_uri>/running/zoning/effective-configuration and <base_uri>/running/brocade-zone/effective-configuration seem to function. I have to assume that in 8.2.X or earlier had adjustments to the REST API URIs made, but not deprecated till FOS 9.X.

My high level ask would be to understand if and when the repo will be updated to use the most up to date URIs which can support FOS 8.2.X and 9.X as well as when that functionality can be imported into a new version of the Brocade FOS Ansible Galaxy Collection - https://galaxy.ansible.com/brocade/fos

atroyblack commented 2 years ago

Here is the full error we were getting for this playbook on one of our attempts -

{
    "changed": false,
    "GET_resp_data": {
        "errors": {
            "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-restconf",
            "error": {
                "error-type": "application",
                "error-tag": "unknown-element",
                "error-app-tag": "Error",
                "error-message": "Invalid REST URI",
                "error-info": {
                    "error-code": "5",
                    "error-module": "rest"
                }
            }
        }
    },
    "GET_url": "https://********/rest/running/zoning/effective-configuration",
    "GET_resp_code": 400,
    "GET_resp_reason": "Bad Request",
    "msg": "failed to checksum",
    "invocation": {
        "module_args": {
            "credential": {
                "fos_ip_addr": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "fos_user_name": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "fos_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "https": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
            },
            "vfid": -1,
            "aliases": [
            <REDACTED>
            ],
            "throttle": null,
            "timeout": null,
            "members_add_only": null,
            "members_remove_only": null,
            "aliases_to_delete": null
        }
    },
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "_ansible_no_log": false
}
sri4kanne commented 2 years ago

Just wanted to check if there are any plans to release an updated collection that is compatible with new API endpoints? @daniel-chung-broadcom for viz

prabhu-broadcom commented 2 years ago

Hi, The zoning uris have been updated in the side branch - documentation_attribute_content_change. The master branch will be updated with this fix in the next release. Please use this side branch in the mean time. These new URIs have been supported from FOS v8.2.1b release.

Thanks,

sri4kanne commented 2 years ago

Thank you @prabhu-broadcom we switched to using collections instead of repo in 2020. Do you know when will the next release be? As temporary fix we are downgrading FOS on brand new switch from the version that was delivered just to make this work. Any help to expedite the release would be much appreciated.

prasad-valmeti-broadcom commented 1 year ago

This is just to give an update. Plan is in progress to merge documentation branch changes into main/galaxy. Will update once the plan is finalized.

sri4kanne commented 1 year ago

Just wanted to check if there was any update on this?

prasad-valmeti-broadcom commented 1 year ago

Ansible fos 1.3.1 is uploaded to galaxy collections. That is available from Apr 2023. Please try and let us know if this resolves the issue.

prasad-valmeti-broadcom commented 1 year ago

If there are no further issues, please suggest if we can close the issue.

prasad-valmeti-broadcom commented 1 year ago

Please let us know if we can close the issue since the issue is already addressed.