My ansible script with JuniperOS encountered command timeout.
Eventhought I’ve increased the timeout to 300 secs, it still failed with timeout error as below:
Loading collection ansible.utils from /usr/share/ansible/collections/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<172.18.8.199> attempting to start connection
<172.18.8.199> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<172.18.8.199> local domain socket does not exist, starting it
<172.18.8.199> control socket path is /root/.ansible/pc/e0eeae5eee
<172.18.8.199> Loading collection ansible.builtin from
<172.18.8.199> Loading collection ansible.netcommon from /usr/share/ansible/collections/ansible_collections/ansible/netcommon
<172.18.8.199> Loading collection ansible.utils from /usr/share/ansible/collections/ansible_collections/ansible/utils
<172.18.8.199> Loading collection junipernetworks.junos from /usr/share/ansible/collections/ansible_collections/junipernetworks/junos
<172.18.8.199> local domain socket listeners started successfully
<172.18.8.199> loaded cliconf plugin ansible_collections.junipernetworks.junos.plugins.cliconf.junos from path /usr/share/ansible/collections/ansible_collections/junipernetworks/junos/plugins/cliconf/junos.py for network_os junipernetworks.junos.junos
<172.18.8.199> ssh type is set to auto
<172.18.8.199> autodetecting ssh_type
<172.18.8.199> ssh type is now set to libssh
<172.18.8.199> Loading collection ansible.builtin from
<172.18.8.199> local domain socket path is /root/.ansible/pc/e0eeae5eee
<172.18.8.199> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<172.18.8.199> ANSIBLE_NETWORK_IMPORT_MODULES: found ansible.netcommon.cli_command at /usr/share/ansible/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py
<172.18.8.199> ANSIBLE_NETWORK_IMPORT_MODULES: running ansible.netcommon.cli_command
<172.18.8.199> ANSIBLE_NETWORK_IMPORT_MODULES: complete
The full traceback is:
File "/usr/share/ansible/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py", line 171, in main
response = connection.get(**module.params)
File "/usr/local/lib/python3.9/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [172.18.8.199]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"answer": null,
"check_all": false,
"command": "show version",
"newline": true,
"prompt": null,
"sendonly": false
}
},
"msg": "command timeout triggered, timeout value is 30 secs.nSee the timeout setting options in the Network Debug and Troubleshooting Guide."
}
My Inventory host file looks like this:
JUNOS:
hosts:
172.18.8.199:
vars:
ansible_user: "root"
ansible_password: "xxxxxx"
ansible_become: yes
ansible_become_method: enable
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: junipernetworks.junos.junos
ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q bastion01"'
My Main file looks like this:
- name: Manage JunOS
hosts: JUNOS
gather_facts: false
tasks:
- name: Retrieve Junos OS version
ansible.netcommon.cli_command:
command: show version
register: admin_facts
- name: Debug
debug:
var: admin_facts
Any ansible configuration I missed out or I need to enable something in my JunOS VM?
PS: I’m using CLI connection instead of NETCONF connection
Increase timeout to 300 seconds, but still failed.