ansible-collections / arista.eos

Ansible Network Collection for Arista EOS
GNU General Public License v3.0
82 stars 69 forks source link

TimeOut when enabling interface defaults ethernet shutdown #277

Open daanvdsanden opened 3 years ago

daanvdsanden commented 3 years ago
SUMMARY

When deploying a config via ssh that enables shutdown interfaces by default the task will TimeOut.

ISSUE TYPE
COMPONENT NAME

arista.eos.eos_config

ANSIBLE VERSION
ansible [core 2.11.4]
  config file = /home/user/arista-poc/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/arista-poc/venv/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/arista-poc/venv/bin/ansible
  python version = 3.9.5 (default, May 12 2021, 20:44:22) [GCC 10.3.1 20210424]
  jinja version = 3.0.1
  libyaml = False
COLLECTION VERSION
# /home/user/arista-poc/venv/lib/python3.9/site-packages/ansible_collections
Collection Version
---------- -------
arista.eos 2.2.0
CONFIGURATION
DEFAULT_JINJA2_EXTENSIONS(/home/user/arista-poc/ansible.cfg) = jinja2.ext.loopcontrols,jinja2.ext.do
DEFAULT_TEST_PLUGIN_PATH(/home/user/arista-poc/ansible.cfg) = ['/home/user/arista-poc/test_plugins']
DUPLICATE_YAML_DICT_KEY(/home/user/arista-poc/ansible.cfg) = error
HOST_KEY_CHECKING(/home/user/arista-poc/ansible.cfg) = False
OS / ENVIRONMENT

Devices running on EOS 4.23.4M and 4.25.4M experience the problem (probably more version are impacted)

STEPS TO REPRODUCE

When you run a task to replace the configuration which contains the following lines (while not in the running config yet) the task will time out:

!
interface defaults
   ethernet
      shutdown
!

I'm using the following task:

- name: replace configuration with intended configuration
  eos_config:
    src: 'config-switch.cfg'
    backup: no
    replace: config
    save_when: modified

I'm using the ssh connection (not eapi).

EXPECTED RESULTS

I'm expecting the configuration to be installed and activated.

ACTUAL RESULTS

The task is not executed because it times out.

The full traceback is:
  File "/tmp/ansible_eos_config_payload__bslaava/ansible_eos_config_payload.zip/ansible/module_utils/network/eos/eos.py", line 174, in load_config
    response = conn.edit_config(commands, commit, replace)
  File "/tmp/ansible_eos_config_payload__bslaava/ansible_eos_config_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [TL-SW-LF001]: FAILED! => {
    "changed": false,
    "data": "timeout value 30 seconds reached while trying to send command: b'shutdown'",
    "invocation": {
        "module_args": {
            "after": null,
            "auth_pass": null,
            "authorize": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "defaults": false,
            "diff_against": "session",
            "diff_ignore_lines": null,
            "host": null,
            "intended_config": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "password": null,
            "port": null,
            "provider": null,
            "replace": "config",
            "running_config": null,
            "save_when": "modified",
            "src": "!RANCID-CONTENT-TYPE: arista\n!\nvlan internal order descending range 4000 4094\n!\ntransceiver qsfp default-mode 4x10G\n!\nservice routing protocols model multi-agent\n!\ninterface defaults\n   ethernet\n      shutdown\n!\naaa authentication login serial-console local\naaa authorization exec default local\naaa authorization serial-console\naaa authorization commands all default local\n!\n",
            "ssh_keyfile": null,
            "timeout": null,
            "transport": null,
            "use_ssl": null,
            "username": null,
            "validate_certs": null
        }
    },
    "msg": "timeout value 30 seconds reached while trying to send command: b'shutdown'"
}

This is probably triggered becouse EOS is asking for extra input that is not in the configuration file see a short screen capture:

TL-SW-LF001#configure session test
TL-SW-LF001(config-s-test)#interface defaults
TL-SW-LF001(config-s-test-interface-defaults)#ethernet
TL-SW-LF001(config-s-test-interface-defaults-ethernet)#shutdown
! This command will change the administrative status of every Ethernet interface that has not yet been specifically configured.
This might include the interface over which this session runs!
Here is the list of affected interfaces:
Et1 Et2 Et3 Et4 Et5 Et6 Et7 Et8

Do you wish to proceed with this command?[yes/no]:
daanvdsanden commented 3 years ago

This is not an issue when using ansible_connection: ansible.netcommon.httpapi

GomathiselviS commented 3 years ago

Hi @daanvdsanden Thank you for submitting this issue. Can I suggest you try eos_command module with prompt handling, instead of eos_config ? You can get more information on how to use eos_command for this purpose from this description.

kdam0 commented 8 months ago

@GomathiselviS even when using the eos_command module I seem to trigger the timeout error message.

I used the exact example from the docs:

- name: run a command that requires a confirmation. Note that prompt
    takes regexes, and so strings containing characters like brackets
    need to be escaped.
  arista.eos.eos_command:
    commands:
      - command: reload power
        prompt: \[confirm\]
        answer: y
        newline: false

Error:

The full traceback is:                                                                                                                                                                                                                                                      
  File "/home/kdam0/.../arista/eos/plugins/module_utils/network/eos/eos.py", line 140, in run_commands                                                                                                                    
    response = connection.run_commands(                                                                                                                                                                                                                                     
               ^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                                                                                                     
  File "/home/kdam0/.venv/ansible211/lib64/python3.11/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__                                                                                                                                               
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)                                                                                                                                                                                         
fatal: [sw1]: FAILED! => {                                                                                                                                                                                                                                    
    "changed": false,                                                                                                                                                                                                                                                       
    "invocation": {                                                                                                                                                                                                                                                         
        "module_args": {                                                                                                                                                                                                                                                    
            "commands": [                                                                                                                                                                                                                                                   
                {                                                                                                                                                                                                                                                           
                    "answer": "y",                                                                                                                                                                                                                                          
                    "check_all": false,                                                                                                                                                                                                                                     
                    "command": "reload power",                                                                                                                                                                                                                              
                    "newline": false,                                                                                                                                                                                                                                       
                    "output": "text",                                                                                                                                                                                                                                       
                    "prompt": "\\[confirm\\]",                                                                                                                                                                                                                              
                    "sendonly": false,                                                                                                                                                                                                                                      
                    "version": "1"                                                                                                    
                }                                                                                                                                                                                                                                                           
            ],                                                                                                                                                                                                                                                              
            "interval": 1,                                                                                                                                                                                                                                                  
            "match": "all",                                                                                                           
            "retries": 10,                                                                                                                                                                                                                                                  
            "wait_for": null                                                                                                                                                                                                                                                
        }                                                                                                                                                                                                                                                                   
    },                                                                                                                                                                                                                                                                      
    "msg": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."                                                                                                                          
}                                                                                                                                                                                                                                                                           

would someone be able to provide some ideas for why this might be happenning? I've even tried with setting the prompt to .* to match everything in case it was my regex. Thanks in advance!