Developer

 View Only
  • 1.  Factory default Aruba AOS-CX using Ansible

    Posted Aug 03, 2025 09:51 AM

    Hi,

    Is there any way to erase the startup-config using aoscx role?

    I'm trying the following Ansible playbook:

    ---
    - hosts: all
      roles:
        - role: arubanetworks.aoscx_role
      gather_facts: false
      vars:
        ansible_connection: network_cli
        ansible_network_os: aoscx
        ansible_python_interpreter: /usr/bin/python3
        ansible_command_timeout: 300
      tasks:
        - name: Erase startup config
          aoscx_command:
            commands:
              - command: 'erase startup-config'
                prompt:
                 - '.*\(y\/n\)\?.*'
                answer:
                 - 'y'
        - name: Wait for switch to be ready
          wait_for:
            timeout: 60
          delegate_to: localhost

    But I'm still getting the following error message:

    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)

     "msg": "command timeout triggered, timeout value is 300 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."

    Is there any way to reset the switch to factory default using Ansible?



    -------------------------------------------


  • 2.  RE: Factory default Aruba AOS-CX using Ansible
    Best Answer

    Posted Aug 05, 2025 04:31 PM

    Hi @tal.madari ! Yes you can! The issue here is with your regex expression - instead of   you should have .*\(y\/n\):.* - there's a slight difference , semicolon versus question mark. Now you'll have multiple commands to match against while attempting to achieve this:

    Here's the output of the switch when entering the commands manually:

    6200# erase startup-config
    This will clear all non-VSF configurations from the star is not present in the stack, this command will remove tll.
    
    Erase checkpoint startup-config ? (y/n): y
    6200# boot system
    Checking if the configuration needs to be saved...
    
    Do you want to save the current configuration (y/n)? n
    
    Checking for updates needed to programmable devices...
    Done checking for updates.
    
    1 non-failsafe device(s) also need to be updated.
    Please run the 'allow-unsafe-updates' command to enable
    
    
    This will reboot the entire switch and render it unavail
    until the process is complete.
    Continue (y/n)? y
    

    Here's the example task

        - name: Erase startup config
          aoscx_command:
            commands:
              - command: 'erase startup-config'
                prompt:
                 - '.*\(y\/n\):.*'
                answer:
                 - 'y'
              - command: 'boot system'
                prompt:
                 - '.*\(y\/n\)\?.*'
                 - '.*\(y\/n\)\?.*'
                answer:
                 - 'n'             
                 - 'y'


    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------



  • 3.  RE: Factory default Aruba AOS-CX using Ansible

    Posted Aug 06, 2025 02:25 AM

    Hi @Tiffany.Chiapuzio-Wong,

    After changing the question mark to a semicolon, it worked perfectly! Thank you for that suggestion.

    However, I'm now encountering an issue with the reboot command. The double prompt handling doesn't seem to be functioning properly, causing the playbook to timeout. There's a brief delay when executing 'boot system' between the first and second command prompts. Is there a way to add a pause or delay between the responses to accommodate this timing?

    -------------------------------------------



  • 4.  RE: Factory default Aruba AOS-CX using Ansible

    Posted Aug 06, 2025 02:21 PM

    Apologies I missed the "check_all: True" command in the block - it should look like this:

        - name: Erase startup config
          aoscx_command:
            commands:
              - command: 'erase startup-config'
                prompt:
                 - '.*\(y\/n\):.*'
                answer:
                 - 'y'
              - command: 'boot system'
                 check_all: True
                prompt:
                 - '.*\(y\/n\)\?.*'
                 - '.*\(y\/n\)\?.*'
                answer:
                 - 'n'             
                 - 'y'


    ------------------------------
    Ti Chiapuzio-Wong (they/them)
    HPE Aruba Networking
    ------------------------------