Unable to copy IOS Image from ansbile to aruba Swtich

Hi,

I am trying to copy an IOS Image from ansible server (my ansible Server is working as TFTP server) to aruba switch, but I am getting below Error. I am trying to achieve this using module “community.network.aruba_command:”.

Could you please tell me the right module to copy as I am unable to find that also.

Playbook

[root@lonans01 arubaymls]# cat copy-ansible-to-switch.yml

  • hosts: arubaswitch
    gather_facts: no
    vars:
    ansible_command_timeout: 2000

    tasks:

    • name: Copy ISO Image from ansible to Aruba Switch
      community.network.aruba_command:
      commands: “copy tftp flash 10.160.106.49 WC_16_08_0006.swi secondary”
      prompt:
      “Continue (y/n)?”
      answer: ‘y’

and error:

[root@lonans01 arubaymls]# ansible-playbook copy-ansible-to-switch.yml
[DEPRECATION WARNING]: [defaults]callback_whitelist option, normalizing names to new standard, use callbacks_enabled instead. This feature will be removed
from ansible-core in version 2.15. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Skipping callback plugin ‘jsnapy’, unable to load

PLAY [arubaswitch] ******************************************************************************************************************************************

TASK [Copy ISO Image from ansible to Aruba Switch] **********************************************************************************************************
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
fatal: [57.6.141.46]: FAILED! => {“changed”: false, “msg”: “Unsupported parameters for (community.network.aruba_command) module: answer, prompt. Supported parameters include: port, host, timeout, match, wait_for (waitfor), ssh_keyfile, username, password, retries, commands, interval.”}

PLAY RECAP **************************************************************************************************************************************************
57.6.141.46 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

[root@lonans01 arubaymls]#

Hello @G24joshi ,

You’re either including non existing parameters to the community.network.aruba_command module or non existent keywords to the task (hard to say if it’s one way or the other with the unformatted code). Check out the docs:

https://docs.ansible.com/ansible/latest/collections/community/network/aruba_command_module.html

Also, the vars_prompt keyword only exists at a play level. If what you wanted is to add prompts to your playbook you should add them to the playbook section (on top):

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_prompts.html

Here is an example of using the vars_prompt keyword at a play level (you cannot use it at a task level):

---
- name: My Playbook
  hosts: arubaswitch
  gather_facts: false
  vars:
    ansible_command_timeout: 2000
  vars_prompt:
    - name: continue
      prompt: "Continue (y/n)?"
  tasks:

    - name: Copy ISO Image from ansible to Aruba Switch
      community.network.aruba_command:
        commands: "copy tftp flash 10.160.106.49 WC_16_08_0006.swi secondary"
      when: continue == 'y'
...

PS: There is also the ansible.builtin.expect module, but it only does allow you to execute shell commands… I guess it won’t be of use to you on this context:

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/expect_module.html

Hope it helps!

I failed to see this:

You might use the ansible.builtin.command to run scp, for example. Or even better, as you want to add prompts, you might try the ansible.builtin.expect module to run the scp command

Or you also could try the ansible.builtin.copy module:

ansible.builtin.copy module – Copy files to remote locations — Ansible Documentation

Hi @jbericat ,

Thanks for your reply.

If we executed command “copy tftp flash 10.160.106.49 WC_16_08_0006.swi secondary” manually over the Aruba Switch it prompts “Continue (y/n)?” and after typing “y” it starts getting copy.

So if we want to do this task from the ansible playbook, then how we can type “y” to Continue.

For your reference I achieved the same thing with Cisco Switch via below Playbook. here you will see I used prompt.


  • hosts: cisco6800
    gather_facts: no
    vars:
    ansible_command_timeout: 1800
    vars_prompt:
    • name: file1
      prompt: Please enter the filename.
      private: false
      tasks:
    • name: COPY FROM Switch to Ansible
      ios_command:
      commands:
      - command: copy tftp://10.160.106.49/{{ file1 }} bootdisk:/{{ file1 }}
      prompt: ‘[{{ file1 }}]’
      answer: “\r”

If possible can you please tell me what would be the right module to copy

That’s because the cisco.ios.ios_command module actually accepts those attributes on the command parameter. Check-out the docs:

https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_command_module.html

Anyway, I just had a wild idea… Have you tried this?

    - name: Copy ISO Image from ansible to Aruba Switch
      community.network.aruba_command:
        commands: 
          - "copy tftp flash 10.160.106.49 WC_16_08_0006.swi secondary"
          - "y"

Cheers

2 Likes

Hi @jbericat

I just tried this and now getting error “Internal error”. Please find below output with -vvvv.

TASK [Copy ISO Image from ansible to Aruba Switch] **********************************************************************************************************
task path: /root/arubaymls/copy-ansible-to-switch-v2.yml:9
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.netcommon from /root/.ansible/collections/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /root/.ansible/collections/ansible_collections/ansible/utils
Loading collection arubanetworks.aos_switch from /root/.ansible/collections/ansible_collections/arubanetworks/aos_switch
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<57.6.141.46> attempting to start connection
<57.6.141.46> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<57.6.141.46> local domain socket does not exist, starting it
<57.6.141.46> control socket path is /root/.ansible/pc/85afccfd3e
<57.6.141.46> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<57.6.141.46> Loading collection ansible.netcommon from /root/.ansible/collections/ansible_collections/ansible/netcommon
<57.6.141.46> Loading collection ansible.utils from /root/.ansible/collections/ansible_collections/ansible/utils
<57.6.141.46> Loading collection arubanetworks.aos_switch from /root/.ansible/collections/ansible_collections/arubanetworks/aos_switch
<57.6.141.46> local domain socket listeners started successfully
<57.6.141.46> loaded cliconf plugin ansible_collections.arubanetworks.aos_switch.plugins.cliconf.arubaoss from path /root/.ansible/collections/ansible_collections/arubanetworks/aos_switch/plugins/cliconf/arubaoss.py for network_os arubanetworks.aos_switch.arubaoss
<57.6.141.46> ssh type is set to auto
<57.6.141.46> autodetecting ssh_type
[WARNING]: ansible-pylibssh not installed, falling back to paramiko
<57.6.141.46> ssh type is now set to paramiko
<57.6.141.46>
<57.6.141.46> local domain socket path is /root/.ansible/pc/85afccfd3e
redirecting (type: modules) community.network.aruba_command to community.network.network.aruba.aruba_command
<57.6.141.46> Using network group action community.network.aruba for community.network.aruba_command
<57.6.141.46> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) community.network.aruba_command to community.network.network.aruba.aruba_command
<57.6.141.46> ANSIBLE_NETWORK_IMPORT_MODULES: found community.network.aruba_command at /usr/local/lib/python3.8/site-packages/ansible_collections/community/network/plugins/modules/network/aruba/aruba_command.py
<57.6.141.46> ANSIBLE_NETWORK_IMPORT_MODULES: running community.network.aruba_command
<57.6.141.46> ANSIBLE_NETWORK_IMPORT_MODULES: complete
fatal: [57.6.141.46]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“commands”: [
“copy tftp flash 10.160.106.49 WC_16_08_0006.swi secondary”,
“y”
],
“host”: null,
“interval”: 1,
“match”: “all”,
“password”: null,
“port”: null,
“retries”: 10,
“ssh_keyfile”: null,
“timeout”: null,
“username”: null,
“wait_for”: null
}
},
“msg”: “Internal error”,
“rc”: -32603
}

meh I was hoping it did… Well, I would like to have a look to the Aruba docs before digging further. Can you paste a show version of the node, pls?

2 Likes

Thanks a lot @jbericat

I have achieved this task by my below playbook.

- name: image upload
  ansible.netcommon.cli_command:
      command: copy tftp flash 10.160.106.49 {{ file1 }} secondary
      prompt: Continue (y/n)?
      answer: y
      newline: false

2 Likes

Great @G24joshi! Thanks for sharing your fix btw :slight_smile:

Cheers