ansible-junos-stdlib
ansible-junos-stdlib copied to clipboard
junos_install_config: apply timeout to initial device connection
junos_install_config has a timeout parameter but it's not used when opening the initial connection to the device, here.
If the device is down or the host/port is incorrect, it can take upwards of 4 minutes to eventually timeout, depending on other defaults.
It would be great if timeout was applied to device.open() as well, so you could limit long timeouts.
This will require some coordination with Juniper/py-junos-eznc.It uses ncclient's manager which does have a timeout parameter, but device.open() doesn't seem to make use of it
I would say this issue does not need a fix in junos_install_config. If there is a concern that a device might not be reachable then use the wait_for task before calling the junos_install_config task The wait_for task checks that a TCP session can be established to the device on a given port and has a timeout option to control how long to give a device to respond.
@AndyMan1 I think your request is valid. As you point out, this capability needs to first be added to PyEZ. Can you please open a corresponding issue against PyEZ?
I feel the workaround @jnpr-bowen suggests by first checking reachability to the device using the wait_for
module is reasonable and best practice for Ansible. However, that doesn't address the native PyEZ need for a connection timeout parameter, and if we implement it in PyEZ we might as well expose it in the Ansible modules.