ansible-collections / community.network

Ansible Community Network Collection
http://galaxy.ansible.com/community/network
Other
124 stars 89 forks source link

EdgeOs alternative for prompts module? #473

Open lowkeylamb opened 2 years ago

lowkeylamb commented 2 years ago
SUMMARY

I'm trying to create a playbook to update a few edge routers to current hotfixes, but I cannot find a way to get around the prompted yes/no question with the supported community.network.edgeos_command module parameters (wait_for, interval, commands, retries, match)

add system image https://www.ui.com/download/edgemax/edgerouter-x/default/edgerouter-er-xer-x-sfpep-r6er-10x-firmware-v209-hotfix4 Version [v2.0.9-hotfix.4.5521907.220630.0657] is about to be replaced Are you sure you want to replace old version? (Yes/No) [Yes]:

ISSUE TYPE
COMPONENT NAME

community.network.edgeos_command module

ANSIBLE VERSION
ansible [core 2.13.4]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/lowkeylamb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/lowkeylamb/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/lowkeylamb/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/lowkeylamb/.local/bin/ansible
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /home/lowkeylamb/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 3.1.1
ansible.utils     2.6.1
community.general 5.6.0
community.network 4.0.1
CONFIGURATION
DEFAULT_HOST_LIST(/etc/ansible/projects/ansible/pi/ansible.cfg) = ['/etc/ansible/projects/ansible/pi/hosts']

Hosts Config:

externaledgerouters:
 hosts:
  ADM-TEST:
   ansible_host: (public IP)
edgerouters:
 vars:
  ansible_connection: network_cli
  ansible_network_os: edgeos
  ansible_ssh_port: (my ssh port)
  ansible_ssh_pass: (my ssh pw)
 children:
  externaledgerouters:
OS / ENVIRONMENT

Windows Terminal 1.14.2281.0 running Ubuntu

Distributor ID: Ubuntu Description: Ubuntu 20.04 LTS Release: 20.04 Codename: focal

STEPS TO REPRODUCE
- name: Update External ERX with latest firmware
  hosts: externaledgerouters
  remote_user: BudAdmin
  tasks:
    - name: Check Image Ver
      community.network.edgeos_command:
       commands: show system image

    - name: Download Hotfix ver2.0.9-hotfix
      community.network.edgeos_command:
       commands: "add system image https://dl.ui.com/firmwares/edgemax/v2.0.9-hotfix.4/ER-e50.v2.0.9-hotfix.4.5521907.tar"
EXPECTED RESULTS

The playbook seems to hang, then eventually times out, because you have to answer yes/no after entering the command:

add system image https://www.ui.com/download/edgemax/edgerouter-x/default/edgerouter-er-xer-x-sfpep-r6er-10x-firmware-v209-hotfix4#

Version [v2.0.9-hotfix.4.5521907.220630.0657] is about to be replaced Are you sure you want to replace old version? (Yes/No) [Yes]:

ACTUAL RESULTS
lowkeylamb@ADM-BRIANLAMB:/etc/ansible/projects/ansible/pi$ ansible-playbook ./playbooks/Ext_ERXfirmware_update.yml -vv
ansible-playbook [core 2.13.4]
  config file = /etc/ansible/projects/ansible/pi/ansible.cfg
  configured module search path = ['/home/lowkeylamb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/lowkeylamb/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/lowkeylamb/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/lowkeylamb/.local/bin/ansible-playbook
  python version = 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
Using /etc/ansible/projects/ansible/pi/ansible.cfg as config file
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: Ext_ERXfirmware_update.yml ****************************************************************************************************************************************************************************
1 plays in ./playbooks/Ext_ERXfirmware_update.yml

PLAY [Update External ERX with latest firmware] *****************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************************************
task path: /etc/ansible/projects/ansible/pi/playbooks/Ext_ERXfirmware_update.yml:1
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.edgeos to community.network.edgeos
redirecting (type: cliconf) ansible.builtin.edgeos to community.network.edgeos
ok: [ADM-TEST]
META: ran handlers

TASK [Check Image Ver] ******************************************************************************************************************************************************************************************
task path: /etc/ansible/projects/ansible/pi/playbooks/Ext_ERXfirmware_update.yml:5
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.edgeos to community.network.edgeos
redirecting (type: cliconf) ansible.builtin.edgeos to community.network.edgeos
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
ok: [ADM-TEST] => {"changed": false, "stdout": ["The system currently has the following image(s) installed:\n\nv2.0.9-hotfix.4.5521907.220630.0657-1 (running image) (default boot) \nv2.0.9-hotfix.4.5521907.220630.0657"], "stdout_lines": [["The system currently has the following image(s) installed:", "", "v2.0.9-hotfix.4.5521907.220630.0657-1 (running image) (default boot) ", "v2.0.9-hotfix.4.5521907.220630.0657"]]}

TASK [Download Hotfix ver2.0.9-hotfix] **************************************************************************************************************************************************************************
task path: /etc/ansible/projects/ansible/pi/playbooks/Ext_ERXfirmware_update.yml:9
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: terminal) ansible.builtin.edgeos to community.network.edgeos
redirecting (type: cliconf) ansible.builtin.edgeos to community.network.edgeos
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
redirecting (type: modules) community.network.edgeos_command to community.network.network.edgeos.edgeos_command
fatal: [ADM-TEST]: FAILED! => {"changed": false, "msg": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}

PLAY RECAP ******************************************************************************************************************************************************************************************************
ADM-TEST                   : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
Qalthos commented 1 year ago

It isn't well documented, but edgeos_command also supports commands being a list of dictionaries similar to eos_command.

If that fails for some reason, the cli_command module should work with edgeos' cliconf plugin to do the correct thing more explicitly.