Skip to content

Commit

Permalink
Use timeout to kill vrnetlab readiness check SSH sessions (#1734)
Browse files Browse the repository at this point in the history
The SSH client used to check vrnetlab readiness can be stuck for
an awfully long when the VM is in just the right phase of getting
ready. This change uses the 'timeout' command (when available) to
kill the check after 5 seconds, allowing the Ansible retry mechanism
to work as expected.
  • Loading branch information
ipspace authored Jan 3, 2025
1 parent 8a19507 commit b3ae80e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion netsim/ansible/tasks/readiness-check/vm-clab-ssh-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
run_once: True
any_errors_fatal: True

- name: Check for 'timeout' command
local_action:
module: shell
cmd: which timeout || echo "FAILED"
changed_when: False
register: have_timeout

- name: Execute local ssh command to check {{ netlab_device_type|default(inventory_hostname) }} readiness
local_action:
module: shell
cmd: |
sshpass -p '{{ ansible_ssh_pass }}' \
{{ 'timeout -k 3s 5s' if "FAILED" not in have_timeout.stdout else '' }} sshpass -p '{{ ansible_ssh_pass }}' \
ssh -o StrictHostKeyChecking=no {{ netlab_ssh_args|default('') }} \
-o UserKnownHostsFile=/dev/null {{ ansible_user }}@{{ ansible_host }} \
'{{ netlab_check_command | default("show version") }}'
Expand Down
2 changes: 1 addition & 1 deletion netsim/devices/vjunos-router.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ clab:
group_vars:
ansible_user: admin
ansible_ssh_pass: admin@123
netlab_check_retries: 40
netlab_check_retries: 60
netlab_check_delay: 10

graphite.icon: router

0 comments on commit b3ae80e

Please sign in to comment.