Skip to content

Instantly share code, notes, and snippets.

@rschrieken rschrieken/mse-327623.md Secret
Created May 2, 2019

Embed
What would you like to do?
Unable to post question

I was exploring ansible and the first step i tried was getting some information from a router (a virtual gns3 image). When i execute the playbook it just hangs and then fails with no error msg.

device os version: JUNOS 17.1R1.8 Kernel 64-bit  JNPR-10.3-20170209.344539_build.
ansible version: 2.7.10
python version: 2.7.15rc1

Directory structure:

├── group_vars
│   └── junosdev.yml
├── inv
├── test.retry
└── test.yml 

content of inv:

[junosdev]
172.16.10.185

content of playbook, test.yml:

- hosts: junosdev
  gather_facts: no
  tasks:
   - name: collect default set of facts and configuration
     junos_facts:

content of group_vars/junosdev:

ansible_connection: network_cli
ansible_network_os: junos
ansible_user: root
ansible_ssh_pass: "Mind@123"

configured parameters in ansible.cfg:

host_key_checking = False
log_path = /opt/log/ansible.log
look_for_keys = False
host_key_auto_add = True

I am able to connect to the device using ssh, get into it's cli and run commands normally but not via ansible. I ran asnible playbook with -vvvvv option and these were the logs.
command- ansible-playbook -vvvvv test.yml -i inv

output:

ansible-playbook 2.7.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/vicky/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/opt/workminuscode/ansiblePractice/try2/inv did not meet host_list requirements, check plugin documentation if this is unexpected
/opt/workminuscode/ansiblePractice/try2/inv did not meet script requirements, check plugin documentation if this is unexpected
Parsed /opt/workminuscode/ansiblePractice/try2/inv inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: test.yml *********************************************************************************************************************************************************************
1 plays in test.yml

PLAY [junosdev] ************************************************************************************************************************************************************************
META: ran handlers

TASK [collect default set of facts and configuration] **********************************************************************************************************************************
task path: /opt/workminuscode/ansiblePractice/try2/test.yml:5
<172.16.10.185> attempting to start connection
<172.16.10.185> using connection plugin network_cli
<172.16.10.185> local domain socket does not exist, starting it
<172.16.10.185> control socket path is /home/vicky/.ansible/pc/210084b20c
<172.16.10.185> 
The full traceback is:
Traceback (most recent call last):
  File "/usr/bin/ansible-connection", line 106, in start
    self.connection._connect()
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py", line 333, in _connect
    newline=self._terminal.terminal_inital_prompt_newline)
  File "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py", line 408, in receive
    data = self._ssh_shell.recv(256)
  File "/home/vicky/.local/lib/python2.7/site-packages/paramiko/channel.py", line 701, in recv
    raise socket.timeout()
timeout

fatal: [172.16.10.185]: FAILED! => {
    "msg": ""
}
	to retry, use: --limit @/opt/workminuscode/ansiblePractice/try2/test.retry

PLAY RECAP *****************************************************************************************************************************************************************************
172.16.10.185              : ok=0    changed=0    unreachable=0    failed=1

The logging was enabled via ansible.cfg file using parameter log_path. Here is the log for this command.

2019-05-02 11:58:58,802 p=7595 u=vicky |  ansible-playbook 2.7.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u&apos;/home/vicky/.ansible/plugins/modules&apos;, u&apos;/usr/share/ansible/plugins/modules&apos;]
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]
2019-05-02 11:58:58,802 p=7595 u=vicky |  Using /etc/ansible/ansible.cfg as config file
2019-05-02 11:58:58,802 p=7595 u=vicky |  setting up inventory plugins
2019-05-02 11:58:58,836 p=7595 u=vicky |  /opt/workminuscode/ansiblePractice/try2/inv did not meet host_list requirements, check plugin documentation if this is unexpected
2019-05-02 11:58:58,836 p=7595 u=vicky |  /opt/workminuscode/ansiblePractice/try2/inv did not meet script requirements, check plugin documentation if this is unexpected
2019-05-02 11:58:58,839 p=7595 u=vicky |  Parsed /opt/workminuscode/ansiblePractice/try2/inv inventory source with ini plugin
2019-05-02 11:58:58,916 p=7595 u=vicky |  Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc
2019-05-02 11:58:58,995 p=7595 u=vicky |  PLAYBOOK: test.yml *********************************************************************************************************************************************************************
2019-05-02 11:58:58,996 p=7595 u=vicky |  1 plays in test.yml
2019-05-02 11:58:59,006 p=7595 u=vicky |  PLAY [junosdev] ************************************************************************************************************************************************************************
2019-05-02 11:58:59,010 p=7595 u=vicky |  META: ran handlers
2019-05-02 11:58:59,018 p=7595 u=vicky |  TASK [collect default set of facts and configuration] **********************************************************************************************************************************
2019-05-02 11:58:59,019 p=7595 u=vicky |  task path: /opt/workminuscode/ansiblePractice/try2/test.yml:5
2019-05-02 11:58:59,384 p=7603 u=vicky |  network_os is set to junos
2019-05-02 11:58:59,419 p=7610 u=vicky | paramiko [172.16.10.185] starting thread (client mode): 0x1b8acbd0L
2019-05-02 11:58:59,419 p=7610 u=vicky | paramiko [172.16.10.185] Local version/idstring: SSH-2.0-paramiko_2.4.2
2019-05-02 11:58:59,435 p=7610 u=vicky | paramiko [172.16.10.185] Remote version/idstring: SSH-2.0-OpenSSH_6.6.1
2019-05-02 11:58:59,435 p=7610 u=vicky | paramiko [172.16.10.185] Connected (version 2.0, client OpenSSH_6.6.1)
2019-05-02 11:58:59,443 p=7610 u=vicky | paramiko [172.16.10.185] kex algos:[u&apos;curve25519-sha256@libssh.org&apos;, u&apos;ecdh-sha2-nistp256&apos;, u&apos;ecdh-sha2-nistp384&apos;, u&apos;ecdh-sha2-nistp521&apos;, u&apos;diffie-hellman-group-exchange-sha256&apos;, u&apos;diffie-hellman-group-exchange-sha1&apos;, u&apos;diffie-hellman-group14-sha1&apos;, u&apos;diffie-hellman-group1-sha1&apos;] server key:[u&apos;ssh-rsa&apos;, u&apos;ssh-dss&apos;, u&apos;ecdsa-sha2-nistp256&apos;, u&apos;ssh-ed25519&apos;] client encrypt:[u&apos;aes128-ctr&apos;, u&apos;aes192-ctr&apos;, u&apos;aes256-ctr&apos;, u&apos;arcfour256&apos;, u&apos;arcfour128&apos;, u&apos;aes128-gcm@openssh.com&apos;, u&apos;aes256-gcm@openssh.com&apos;, u&apos;chacha20-poly1305@openssh.com&apos;, u&apos;aes128-cbc&apos;, u&apos;3des-cbc&apos;, u&apos;blowfish-cbc&apos;, u&apos;cast128-cbc&apos;, u&apos;aes192-cbc&apos;, u&apos;aes256-cbc&apos;, u&apos;arcfour&apos;, u&apos;rijndael-cbc@lysator.liu.se&apos;] server encrypt:[u&apos;aes128-ctr&apos;, u&apos;aes192-ctr&apos;, u&apos;aes256-ctr&apos;, u&apos;arcfour256&apos;, u&apos;arcfour128&apos;, u&apos;aes128-gcm@openssh.com&apos;, u&apos;aes256-gcm@openssh.com&apos;, u&apos;chacha20-poly1305@openssh.com&apos;, u&apos;aes128-cbc&apos;, u&apos;3des-cbc&apos;, u&apos;blowfish-cbc&apos;, u&apos;cast128-cbc&apos;, u&apos;aes192-cbc&apos;, u&apos;aes256-cbc&apos;, u&apos;arcfour&apos;, u&apos;rijndael-cbc@lysator.liu.se&apos;] client mac:[u&apos;hmac-md5-etm@openssh.com&apos;, u&apos;hmac-sha1-etm@openssh.com&apos;, u&apos;umac-64-etm@openssh.com&apos;, u&apos;umac-128-etm@openssh.com&apos;, u&apos;hmac-sha2-256-etm@openssh.com&apos;, u&apos;hmac-sha2-512-etm@openssh.com&apos;, u&apos;hmac-ripemd160-etm@openssh.com&apos;, u&apos;hmac-sha1-96-etm@openssh.com&apos;, u&apos;hmac-md5-96-etm@openssh.com&apos;, u&apos;hmac-md5&apos;, u&apos;hmac-sha1&apos;, u&apos;umac-64@openssh.com&apos;, u&apos;umac-128@openssh.com&apos;, u&apos;hmac-sha2-256&apos;, u&apos;hmac-sha2-256-96&apos;, u&apos;hmac-sha2-512&apos;, u&apos;hmac-sha2-512-96&apos;, u&apos;hmac-ripemd160&apos;, u&apos;hmac-ripemd160@openssh.com&apos;, u&apos;hmac-sha1-96&apos;, u&apos;hmac-md5-96&apos;] server mac:[u&apos;hmac-md5-etm@openssh.com&apos;, u&apos;hmac-sha1-etm@openssh.com&apos;, u&apos;umac-64-etm@openssh.com&apos;, u&apos;umac-128-etm@openssh.com&apos;, u&apos;hmac-sha2-256-etm@openssh.com&apos;, u&apos;hmac-sha2-512-etm@openssh.com&apos;, u&apos;hmac-ripemd160-etm@openssh.com&apos;, u&apos;hmac-sha1-96-etm@openssh.com&apos;, u&apos;hmac-md5-96-etm@openssh.com&apos;, u&apos;hmac-md5&apos;, u&apos;hmac-sha1&apos;, u&apos;umac-64@openssh.com&apos;, u&apos;umac-128@openssh.com&apos;, u&apos;hmac-sha2-256&apos;, u&apos;hmac-sha2-256-96&apos;, u&apos;hmac-sha2-512&apos;, u&apos;hmac-sha2-512-96&apos;, u&apos;hmac-ripemd160&apos;, u&apos;hmac-ripemd160@openssh.com&apos;, u&apos;hmac-sha1-96&apos;, u&apos;hmac-md5-96&apos;] client compress:[u&apos;none&apos;, u&apos;zlib@openssh.com&apos;] server compress:[u&apos;none&apos;, u&apos;zlib@openssh.com&apos;] client lang:[u&apos;&apos;] server lang:[u&apos;&apos;] kex follows?False
2019-05-02 11:58:59,444 p=7610 u=vicky | paramiko [172.16.10.185] Kex agreed: ecdh-sha2-nistp256
2019-05-02 11:58:59,444 p=7610 u=vicky | paramiko [172.16.10.185] HostKey agreed: ssh-ed25519
2019-05-02 11:58:59,444 p=7610 u=vicky | paramiko [172.16.10.185] Cipher agreed: aes128-ctr
2019-05-02 11:58:59,445 p=7610 u=vicky | paramiko [172.16.10.185] MAC agreed: hmac-sha2-256
2019-05-02 11:58:59,447 p=7610 u=vicky | paramiko [172.16.10.185] Compression agreed: none
2019-05-02 11:58:59,462 p=7610 u=vicky | paramiko [172.16.10.185] kex engine KexNistp256 specified hash_algo &lt;built-in function openssl_sha256&gt;
2019-05-02 11:58:59,462 p=7610 u=vicky | paramiko [172.16.10.185] Switch to new keys ...
2019-05-02 11:58:59,567 p=7610 u=vicky | paramiko [172.16.10.185] userauth is OK
2019-05-02 11:58:59,610 p=7610 u=vicky | paramiko [172.16.10.185] Authentication (password) successful!
2019-05-02 11:58:59,615 p=7610 u=vicky | paramiko [172.16.10.185] [chan 0] Max packet in: 32768 bytes
2019-05-02 11:58:59,618 p=7610 u=vicky | paramiko [172.16.10.185] [chan 0] Max packet out: 32768 bytes
2019-05-02 11:58:59,618 p=7610 u=vicky | paramiko [172.16.10.185] Secsh channel 0 opened.
2019-05-02 11:58:59,624 p=7610 u=vicky | paramiko [172.16.10.185] [chan 0] Sesch channel 0 request ok
2019-05-02 11:58:59,631 p=7610 u=vicky | paramiko [172.16.10.185] [chan 0] Sesch channel 0 request ok
2019-05-02 11:59:09,739 p=7595 u=vicky |  The full traceback is:
Traceback (most recent call last):
  File &quot;/usr/bin/ansible-connection&quot;, line 106, in start
    self.connection._connect()
  File &quot;/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py&quot;, line 333, in _connect
    newline=self._terminal.terminal_inital_prompt_newline)
  File &quot;/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py&quot;, line 408, in receive
    data = self._ssh_shell.recv(256)
  File &quot;/home/vicky/.local/lib/python2.7/site-packages/paramiko/channel.py&quot;, line 701, in recv
    raise socket.timeout()
timeout

2019-05-02 11:59:09,741 p=7595 u=vicky |  fatal: [172.16.10.185]: FAILED! =&gt; {
    &quot;msg&quot;: &quot;&quot;
}
2019-05-02 11:59:09,742 p=7595 u=vicky |  	to retry, use: --limit @/opt/workminuscode/ansiblePractice/try2/test.retry

2019-05-02 11:59:09,742 p=7595 u=vicky |  PLAY RECAP *****************************************************************************************************************************************************************************
2019-05-02 11:59:09,742 p=7595 u=vicky |  172.16.10.185              : ok=0    changed=0    unreachable=0    failed=1   
2019-05-02 11:59:09,808 p=7603 u=vicky |  shutdown complete
2019-05-02 11:59:09,811 p=7610 u=vicky | paramiko [172.16.10.185] EOF in transport thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.