community.network
community.network copied to clipboard
aireos_command cannot answer prompts of the commands it sends
SUMMARY
While sending commands to aireos devices that trigger a prompt, the module cannot handle the prompt/ For example if I try to copy a file to from the device using the transfer command: (Cisco Controller) User: admin Password:******** Welcome to the Cisco Mobility Express command line interface. Only commands which are listed in the command reference guide for this release are supported. http://www.cisco.com/c/en/us/support/wireless/mobility-express/products-command-reference-list.html (Cisco Controller) >transfer download datatype config
(Cisco Controller) >transfer download mode tftp
(Cisco Controller) >transfer download serverip 172.25.1.1
(Cisco Controller) >transfer download filename config.txt
(Cisco Controller) >transfer download start
Mode............................................. TFTP
Data Type........................................ Config
TFTP Server IP................................... 172.25.1.1
TFTP Packet Timeout.............................. 6
TFTP Max Retries................................. 10
TFTP Path........................................
TFTP Filename.................................... config.txt
Encrypt/Decrypt Flag............................. Disabled
Warning: Downloading configuration will cause the controller to reset...
This may take some time. Are you sure you want to start? (y/N) y
TFTP Config transfer starting.
TFTP receive complete... updating configuration.
TFTP receive complete... storing in flash.
Sync config to peers.
System being reset.
The module just times out even if I send the command with a carriage return followed by an y: transfer download start\ry This is because after this command there will be no prompt to catch.
ISSUE TYPE
- Bug Report
COMPONENT NAME
aireos_command
ANSIBLE VERSION
ansible 2.9.2
config file = /home/automation/projects/wifi/ansible.cfg
configured module search path = ['/home/automation/projects/wifi/lib/python3.7/site-packages/napalm_ansible']
ansible python module location = /home/automation/projects/wifi/lib/python3.7/site-packages/ansible
executable location = /home/automation/projects/wifi/bin/ansible
python version = 3.7.6 (default, Feb 11 2020, 08:19:12) [GCC 7.4.0]
CONFIGURATION
DEFAULT_CALLBACK_WHITELIST(/home/automation/projects/wifi/ansible.cfg) = ['profile_tasks']
DEFAULT_FORKS(/home/automation/projects/wifi/ansible.cfg) = 50
DEFAULT_GATHERING(/home/automation/projects/wifi/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/home/automation/projects/wifi/ansible.cfg) = ['/home/automation/projects/wifi/inventory/localhost/inven
DEFAULT_LOG_PATH(/home/automation/projects/wifi/ansible.cfg) = /home/automation/projects/wifi/logs/ansible.log
DEFAULT_MODULE_PATH(/home/automation/projects/wifi/ansible.cfg) = ['/home/automation/projects/wifi/lib/python3.7/site-pack
DEFAULT_REMOTE_USER(/home/automation/projects/wifi/ansible.cfg) = automation
DEFAULT_ROLES_PATH(/home/automation/projects/wifi/ansible.cfg) = ['/home/automation/projects/wifi/roles']
DEFAULT_STDOUT_CALLBACK(/home/automation/projects/wifi/ansible.cfg) = debug
DEFAULT_TIMEOUT(/home/automation/projects/wifi/ansible.cfg) = 60
DEFAULT_TRANSPORT(/home/automation/projects/wifi/ansible.cfg) = network_cli
DEFAULT_VAULT_PASSWORD_FILE(/home/automation/projects/wifi/ansible.cfg) = /home/automation/projects/wifi/vault_pass
DEPRECATION_WARNINGS(/home/automation/projects/wifi/ansible.cfg) = False
HOST_KEY_CHECKING(/home/automation/projects/wifi/ansible.cfg) = False
PLAYBOOK_DIR(/home/automation/projects/wifi/ansible.cfg) = /home/automation/projects/wifi/playbooks
RETRY_FILES_ENABLED(/home/automation/projects/wifi/ansible.cfg) = False
OS / ENVIRONMENT
NAME: "Mobility Express" , DESCR: "Cisco Aironet 2800 Series Mobility Express" PID: AIR-AP2802I-E-K9, Image version: 8.8.125.0
STEPS TO REPRODUCE
tasks:
- name: config transfer
aireos_command:
provider:
host: "{{ ansible_host }}"
username: "{{ username }}"
password: "{{ password }}"
commands:
- "transfer download datatype config"
- "transfer download mode tftp"
- "transfer download serverip 172.25.1.1"
- "transfer download path /"
- "transfer download filename config.txt"
- "transfer download start"
EXPECTED RESULTS
I would expect a changed result. I also tried this with aireos_config and it doesn't work with to many config changes. Because there is no way to turn of prompts like on ios with file prompt quiet, I would expect the module to be able to handle this.
ACTUAL RESULTS
ansible-playbook 2.9.2
config file = /******************************/ansible.cfg
configured module search path = ['/******************************/lib/python3.7/site-packages/napalm_ansible']
ansible python module location = /******************************/lib/python3.7/site-packages/ansible
executable location = /******************************/bin/ansible-playbook
python version = 3.7.6 (default, Feb 11 2020, 08:19:12) [GCC 7.4.0]
Using /******************************/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /******************************/inventory/access/access.yml as it did not pass its verify_file() method
script declined parsing /******************************/inventory/access/access.yml as it did not pass its verify_file() method
Parsed /******************************/inventory/access/access.yml inventory source with yaml plugin
Loading callback plugin debug of type stdout, v2.0 from /******************************/lib/python3.7/site-packages/ansible/plugins/callback/debug.py
Loading callback plugin profile_tasks of type aggregate, v2.0 from /******************************/lib/python3.7/site-packages/ansible/plugins/callback/profile_tasks.py
PLAYBOOK: aireos_transfer.yml ********************************************************************************************
Positional arguments: playbooks/aireos_transfer.yml
verbosity: 4
remote_user: automation
connection: network_cli
timeout: 60
become_method: sudo
tags: ('all',)
inventory: ('/******************************/inventory/access/access.yml',)
forks: 50
1 plays in playbooks/aireos_transfer.yml
PLAY [Download config file] **********************************************************************************************
META: ran handlers
TASK [config transfer] ***************************************************************************************************
task path: /******************************/playbooks/aireos_transfer.yml:8
Tuesday 16 June 2020 14:38:48 +0300 (0:00:00.150) 0:00:00.150 **********
<10.1.7.10> using connection plugin network_cli (was local)
<10.1.7.10> starting connection from persistent connection plugin
<10.1.7.10> local domain socket does not exist, starting it
<10.1.7.10> control socket path is /home/automation/.ansible/pc/8db2cc55bb
<10.1.7.10> local domain socket listeners started successfully
<10.1.7.10> loaded cliconf plugin aireos from path /******************************/lib/python3.7/site-packages/ansible/plugins/cliconf/aireos.py for network_os aireos
<10.1.7.10>
<10.1.7.10> local domain socket path is /home/automation/.ansible/pc/8db2cc55bb
<10.1.7.10> socket_path: /home/automation/.ansible/pc/8db2cc55bb
<10.1.7.10> ESTABLISH LOCAL CONNECTION FOR USER: automation
<10.1.7.10> EXEC /bin/sh -c 'echo ~automation && sleep 0'
<10.1.7.10> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878 `" && echo ansible-tmp-1592307530.7794464-262784945996878="` echo /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878 `" ) && sleep 0'
Using module file /******************************/lib/python3.7/site-packages/ansible/modules/network/aireos/aireos_command.py
<10.1.7.10> PUT /home/automation/.ansible/tmp/ansible-local-118032ngaoao1_/tmpnvkxrwh8 TO /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878/AnsiballZ_aireos_command.py
<10.1.7.10> EXEC /bin/sh -c 'chmod u+x /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878/ /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878/AnsiballZ_aireos_command.py && sleep 0'
<10.1.7.10> EXEC /bin/sh -c '/usr/bin/env python /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878/AnsiballZ_aireos_command.py && sleep 0'
<10.1.7.10> EXEC /bin/sh -c 'rm -f -r /home/automation/.ansible/tmp/ansible-tmp-1592307530.7794464-262784945996878/ > /dev/null 2>&1 && sleep 0'
fatal: [*************-cap]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"commands": [
"transfer download datatype config",
"transfer download mode tftp",
"transfer download serverip 172.25.1.1",
"transfer download path /",
"transfer download filename config.txt",
"transfer download start"
],
"host": null,
"interval": 1,
"match": "all",
"password": null,
"port": null,
"provider": {
"host": "10.1.1.1",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": null,
"ssh_keyfile": null,
"timeout": null,
"username": "automation"
},
"retries": 10,
"ssh_keyfile": null,
"timeout": null,
"username": null,
"wait_for": null
}
},
"rc": -32603
}
MSG:
command timeout triggered, timeout value is 30 secs.
See the timeout setting options in the Network Debug and Troubleshooting Guide.
...ignoring
META: ran handlers
META: ran handlers
PLAY RECAP ***************************************************************************************************************
**************-cap : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1
Tuesday 16 June 2020 14:39:21 +0300 (0:00:33.414) 0:00:33.564 **********
===============================================================================
config transfer -------------------------------------------------------------------------------------------------- 33.41s
/*******************************/aireos_transfer.yml:8 ----------------------------------------------------------
Files identified in the description:
If these files are inaccurate, please update the component name
section of the description or use the !component
bot command.
@mpsOxygen, just so you are aware we have a dedicated Working Group for network.
You can find other people interested in this in #ansible-network
on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community
A workaround is to pass the y into the command line string.
Change: - "transfer download start"
to: - "transfer download start\ry"
Yes, that is the way I ended up doing it.
Hi all,
You can separate the transfer download start as a separate play. Then use wait_for: [y/N] prompt, then answer y.
A workaround is to pass the y into the command line string.
Change: - "transfer download start"
to: - "transfer download start\ry"
This is not working for me... I am trying to save config with command "save config" and it is giving me prompt like Are "you sure you want to save? (y/n)" I tried to pass /y but not working.