Hello! I'm evaluating ansible to configure network switches and observed
that the task result is not correct if the switch is not reachable. Using
network_cli it's always 'failed' where I'd expect 'unreachable". A minimal
working example using localhost:
host.yml:
all:
hosts:
local:
ansible_host: 127.0.0.1
playbook.yml:
---
- name: test unreachable state with network_cli
hosts: all
vars:
ansible_connection: network_cli
ansible_network_os: ios
gather_facts: no
tasks:
- cli_command:
command: exit
result:
# ansible-playbook -i hosts.yml playbook.yml
PLAY [test unreachable state with network_cli]
TASK [cli_command]
fatal: [local]: FAILED! => {"ansible_facts":
{"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false,
"msg": "[Errno None] Unable to connect to port 22 on 127.0.0.1"}
PLAY RECAP
local : ok=0 changed=0 unreachable=0
*failed=1* skipped=0 rescued=0 ignored=0
Sure, localhost isn't a IOS switch but I'd expect the same result as with
ssh:
---
- name: test unreachable state with ssh
hosts: all
vars:
ansible_connection: ssh
gather_facts: no
tasks:
- command: exit
which shows correctly
PLAY [test unreachable state with ssh]
TASK [command] fatal: [local]: UNREACHABLE! => {"changed": false, "msg":
"Failed to connect to the host via ssh: ssh: connect to host 127.0.0.1 port
22: Connection refused", "unreachable": true}
PLAY RECAP
local : ok=0 changed=0 *unreachable=1*
failed=0 skipped=0 rescued=0 ignored=0
As I'm quite new in this field there might something wrong or should I
report a bug? From the source code it seems that the exceptions are not
properly propagated.
Using ansible 2.9.13 on Linux.
Thanks
Greg
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/2f905864-5347-4068-bf65-229f63760b17n%40googlegroups.com.