Apologies I missed the "check_all: True" command in the block - it should look like this:
Original Message:
Sent: Aug 06, 2025 02:25 AM
From: tal.madari
Subject: Factory default Aruba AOS-CX using Ansible
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?
Original Message:
Sent: Aug 05, 2025 04:31 PM
From: Tiffany.Chiapuzio-Wong
Subject: Factory default Aruba AOS-CX using Ansible
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-configThis 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): y6200# boot systemChecking if the configuration needs to be saved...Do you want to save the current configuration (y/n)? nChecking 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 enableThis will reboot the entire switch and render it unavailuntil 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
Original Message:
Sent: Aug 03, 2025 09:51 AM
From: tal.madari
Subject: Factory default Aruba AOS-CX using Ansible
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?
-------------------------------------------