aruba/aos-switch-ansible-collection

"msg": "Negative size passed to PyBytes_FromStringAndSize"

Closed this issue · 3 comments

Hello there,
I am trying to do the following with cli_command module:

- hosts: SW-B
  collections:
    - arubanetworks.aos_switch
  vars:
    ansible_connection: network_cli
  tasks:
    - name: Upload Image to secondary flash and reboot the switch
      arubaoss_command:
        commands:
          - command: "copy tftp flash X.X.X.X YA_16_11_0008.swi secondary"
            prompt:
              - "Continue (y/n)?"
            answer:
              - y
    - name: Boot on the new secondary Image
      arubaoss_command:
        commands:
          - command: "boot system flash secondary"
            prompt:
              - "Continue (y/n)?"
            answer:
              - y
  • upload a YA_16_11_008 into secondary flash of a aos switch that has YA_15_18_xxx image
  • boot the switch into secondary image
    the image uploads and the switch reboots but i get a fatal error on the boot task:
PLAY [SW-BA0-1] *************************************************************

TASK [Gathering Facts] ********************************************************
ok: [SW-BA0-1]

TASK [Upload Image to secondary flash and reboot the switch] ********************************************************************************
ok: [SW-BA0-1]

TASK [Boot on the new secondary Image] ***********************************
fatal: [SW-BA0-1]: FAILED! => {"changed": false, "msg": "Negative size passed to PyBytes_FromStringAndSize"}

PLAY RECAP *******************************************************************
SW-BA0-1                   : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

does anyone have any idea why i am getting this error?
the switch is:
2530-48G (J9775A)

thanks in advance

What do you have if you enable more verbose ?

@ershad-ra this is expected due to the SSH module searching for/expecting to receive the switch prompt after a command is finished - in this case it's receiving the bytes due to the reboot. A workaround is to change the criteria of when the module fails like so:

    - name: Reboot Switch
      arubaoss_command:
        commands:
          - command: "boot system flash primary"
            check_all: true
            prompt:
              - '.*\(y\/n\)\?.*'
              - '.*\(y\/n\)\?.*'
            answer:
              - 'y'
              - 'y'
      register: result
      failed_when: '"Negative size passed to PyBytes_FromStringAndSize" not in result.msg'
      # it will error because characters are returned instead of expected prompt
	  # so you must define a specific failure

@tchiapuziowong thanks a lot for the explanation and the workaround ! it worked very well !

by the way, this is the output i had before with more verbose:

The full traceback is:
  File "/tmp/ansible_arubaoss_command_payload_busukqsq/ansible_arubaoss_command_payload.zip/ansible_collections/arubanetworks/aos_switch/plugins/module_utils/arubaoss.py", line 432, in run_cli_commands
    return conn.run_commands(commands=commands, check_rc=check_rc)
  File "/tmp/ansible_arubaoss_command_payload_busukqsq/ansible_arubaoss_command_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [SW-SERVICE-INFO]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "api_version": "None",
            "commands": [
                {
                    "answer": [
                        "y"
                    ],
                    "check_all": false,
                    "command": "boot system flash secondary",
                    "newline": true,
                    "prompt": [
                        ".*\\(y\\/n\\)\\?.*"
                    ],
                    "sendonly": false
                }
            ],
            "host": null,
            "interval": 1,
            "match": "all",
            "output_file": null,
            "password": null,
            "port": null,
            "provider": {
                "api_version": null,
                "host": "10.31.12.63",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": 80,
                "ssh_keyfile": null,
                "timeout": 100,
                "transport": "aossapi",
                "use_proxy": false,
                "use_ssl": false,
                "username": "ignace",
                "validate_certs": false
            },
            "retries": 10,
            "ssh_keyfile": null,
            "timeout": null,
            "use_ssl": null,
            "username": null,
            "validate_certs": false,
            "wait_for": null
        }
    },
    "msg": "Negative size passed to PyBytes_FromStringAndSize"
}