aruba / aoscx-ansible-collection

Ansible collections for AOS-CX switches 
48 stars 23 forks source link

Firmware upload not working on 6300 CX switch #11

Closed jon-larsen closed 2 years ago

jon-larsen commented 3 years ago

I'm using Ansible to upload firmware. It works fine on a CX 6200F, but it fails on the 6300.

---
- hosts: switch
  roles:
    - role: arubanetworks.aoscx_role
  gather_facts: False
  any_errors_fatal: true
  tasks:

# Check current firmware version
    - name: Get current firmware version
      aoscx_facts:
        gather_subset: ['software_version','software_images']
      register: fact_current_version

    - name: Set current_version variable
      set_fact:
        current_version: "{{ fact_current_version['ansible_facts']['ansible_net_software_version'] }}"

    - name: Set image_version variable
      set_fact:
        image_version: "{{ fact_current_version['ansible_facts']['ansible_net_software_images'][boot_partition + '_image_version'] }}"
    - name: show firmware name
      set_fact:
        firmware_file: "{{ firmware_filename }}"

# Upload firmware (unless firmware already exists)
    - name: Upload firmware through local file
      throttle: 1
      aoscx_upload_firmware:
        partition_name: '{{ boot_partition }}'
        firmware_file_path: '/{{ firmware_filename }}'
      when: image_version is not regex('..\.' + firmware)
TASK [Upload firmware through local file] **********************************************************************************************************
task path: /firmware-upload.yml:27
<switch> attempting to start connection
<switch> using connection plugin arubanetworks.aoscx
<switch> found existing local domain socket, using it!
<switch> 
<switch> local domain socket path is /root/.ansible/pc/a9c72f3811
<switch> ESTABLISH LOCAL CONNECTION FOR USER: root
<switch> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481 `" && echo ansible-tmp-1634738943.6163135-277936768931481="` echo /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481 `" ) && sleep 0'
Using module file /root/.ansible/roles/arubanetworks.aoscx_role/library/aoscx_upload_firmware.py
<switch> PUT /root/.ansible/tmp/ansible-local-16651zsoej9ft/tmpsxyuo94m TO /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481/AnsiballZ_aoscx_upload_firmware.py
<switch> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481/ /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481/AnsiballZ_aoscx_upload_firmware.py && sleep 0'
<switch> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481/AnsiballZ_aoscx_upload_firmware.py && sleep 0'
<switch> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-16651zsoej9ft/ansible-tmp-1634738943.6163135-277936768931481/ > /dev/null 2>&1 && sleep 0'
fatal: [switch]: FAILED! => {
    "changed": false,
    "module_stderr": "Killed\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 137
}
tchiapuziowong commented 3 years ago

Hi @jon-larsen ! Can you provide the firmwares you're using? The one you're attempting to put onto the switch and the one already existing? Also could you provide the output of running the playbook in -vvvv ?

jon-larsen commented 3 years ago

When checking the firmware, I noticed that the firmware for the 6300 switch is twice the size as of the 6200 and 8325, so I expanded the memory on the server I am running Ansible on, and it solved the problem!

I assume this also will fix the problem I have when uploading firmware to multiple switches at once (which is another problem I was thinking about reporting).

bozocorbalizer commented 3 years ago

Hi, had a similar probleme today. with -vvv got the following: File \"/tmp/ansible_aoscx_upload_firmware_payload__mns8tid/ansible_aoscx_upload_firmware_payload.zip/ansible_collections/arubanetworks/aoscx/plugins/modules/aoscx_upload_firmware.py\", line 132, in main\nAttributeError: 'Device' object has no attribute 'device'\n", went to aoscx_upload_firmware.py and commented line 131 (device = device.device()). The problem seems to be present in 3 files: aoscx_banner.py:
aoscx_boot_firmware.py:
aoscx_upload_firmware.py:

tchiapuziowong commented 3 years ago

I'm looking into this - it may be a limitation of behavior with the requests library - @bozocorbalizer are you using the 6300 platform as well?

bozocorbalizer commented 3 years ago

yes, I was testing both aoscx (6300M) and aos_switch (3810M) collections to see if we could use them in our new automation project.

Also ran into the "unterminated character set at position 0" and had to downgrade the ansible version.

python3 --version Python 3.8.10

ansible-galaxy --version ansible-galaxy 2.9.24

python3 -m pip show ansible Name: ansible Version: 2.9.24

python3 -m pip show pyaoscx Name: pyaoscx Version: 2.1.0

python3 -m pip list Package Version


ansible 2.9.24 attrs 19.3.0 Automat 0.8.0 bcrypt 3.1.7 beautifulsoup4 4.10.0 blinker 1.4 bs4 0.0.1 certifi 2019.11.28 chardet 3.0.4 Click 7.0 cloud-init 21.2 colorama 0.4.3 command-not-found 0.3 commonmark 0.9.1 configobj 5.0.6 constantly 15.1.0 cryptography 2.8 dbus-python 1.2.16 distro 1.4.0 distro-info 0.23ubuntu1 entrypoints 0.3 httplib2 0.14.0 hyperlink 19.0.0 idna 2.8 importlib-metadata 1.5.0 incremental 16.10.1 Jinja2 2.10.1 jsonpatch 1.22 jsonpointer 2.0 jsonschema 3.2.0 keyring 18.0.1 language-selector 0.1 launchpadlib 1.10.13 lazr.restfulclient 0.14.2 lazr.uri 1.0.3 MarkupSafe 1.1.0 more-itertools 4.2.0 netaddr 0.8.0 netifaces 0.10.4 oauthlib 3.1.0 packaging 20.3 paramiko 2.6.0 pexpect 4.6.0 pip 20.0.2 pyaoscx 2.1.0 pyasn1 0.4.2 pyasn1-modules 0.2.1 Pygments 2.10.0 PyGObject 3.36.0 PyHamcrest 1.9.0 PyJWT 1.7.1 pymacaroons 0.13.0 PyNaCl 1.3.0 pyOpenSSL 19.0.0 pyparsing 2.4.6 pyrsistent 0.15.5 pyserial 3.4 python-apt 2.0.0+ubuntu0.20.4.5 python-debian 0.1.36ubuntu1 PyYAML 5.3.1 requests 2.22.0 requests-unixsocket 0.2.0 resolvelib 0.5.4 rich 10.12.0 SecretStorage 2.3.1 service-identity 18.1.0 setuptools 45.2.0 simplejson 3.16.0 six 1.14.0 sos 4.1 soupsieve 2.2.1 ssh-import-id 5.10 systemd-python 234 Twisted 18.9.0 ubuntu-advantage-tools 27.2 ufw 0.36 unattended-upgrades 0.1 urllib3 1.25.8 wadllib 1.3.3 wheel 0.34.2 zipp 1.0.0 zope.interface 4.7.1

tchiapuziowong commented 2 years ago

Our development team is looking into the "AttributeError: 'Device' object has no attribute 'device'" error and I'll update the issue as soon as we've pushed a resolution! Thank you for your patience!

tchiapuziowong commented 2 years ago

I've uploaded a fix for this issue in the latest version of the collection - please update your collection by using the below command: ansible-galaxy collection install arubanetworks.aoscx -f