Are you developing directly against source from the devel branch?  Take a
look at this and see if it helps you.

https://github.com/ansible/community/blob/master/group-network/network_dev_network_cli.rst

Is your code in a publicly viewable place?



On Wed, Nov 29, 2017 at 8:01 PM 강동인 <gang...@gmail.com> wrote:

>
> Good morning. I'm trying to develop a network module, but I've been stuck
> here for a few days.
>
> I am having a hard time because of the persistent connection code.
>
> I have noticed that there was a socket handler file in the "~/.ansible/pc"
> folder and we can use persistent connection through this handler.
>
> But when I run the code, the socket path name is created, but the handler
> file is not created and an error occurred.
>
>
>
> When I analyzed the code, I noticed that there was a problem with the "
> /usr/bin/ansible-connection" code. Exactly the problem occurred in the
> code below.
>
>
>
> ###################### ANSIBLE CODE in /usr/bin/ansible-connection
> #######################
>
>
>
> def main():
>
>   .
>
>   .
>
>     server = Server(socket_path, pc)
>
>   .
>
>   .
>
>
>
> class Server():
>
>   .
>
>   .
>
>     self.connection = connection_loader.get(play_context.connection,
> play_context, sys.stdin)
>
>     self.connection._connect()
>
>   .
>
>   .
>
>
> ##################################################################################
>
>
>
>  Also  In the attached log file, the socket path name is generated but handler
> file is not generated and I get an error. I do not know where the code
> that generates the socket handler file is. If you have time, please listen
> to the beginner's cries.
>
>
>
>
>
> *Ansible Log File*
>
>
>
> kos is my new network os and kos_config, kos_command is my custom module
>
> I copied and used cisco ios module to test
>
> In this log, There is also my custom log.
>
>
> *Blod*: I think this is important.
>
> Green : My Opinion
>
>
>
>
> 2017-11-30 00:47:28,656 p=29645 u=docker |  PLAY [GET STRUCTURED DATA BACK
> FROM CLI DEVICES] *********************************
>
> 2017-11-30 00:47:28,669 p=29645 u=docker |  TASK [netscaler test]
> ************************************************************
>
> 2017-11-30 00:47:28,681 action-__init__.py plugins/action/__init__.py/init
>
> 2017-11-30 00:47:28,681 action/kos_config.py plugins/action/
> kos_config.py/run
>
> 2017-11-30 00:47:28,683 action-kos_command action/kos_command.py -
> connection
>
> 2017-11-30 00:47:28,683 action-kos_command
> <ansible.plugins.connection.persistent.Connection object at 0x7f115dd18c50>
>
> 2017-11-30 00:47:28,684 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/run
>
> 2017-11-30 00:47:28,684 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/_do_it
>
> 2017-11-30 00:47:28,684 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/_do_it - master
>
> 2017-11-30 00:47:28,684 plugins/connection/persistent.py 20
>
> 2017-11-30 00:47:28,684 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/_do_it - slave
>
> 2017-11-30 00:47:28,684 plugins/connection/persistent.py 22
>
> 2017-11-30 00:47:29,034 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/main - socket_path
>
> 2017-11-30 00:47:29,034 /usr/bin/ansible-connection.py
> /home/docker/.ansible/pc/7d194f7854
>
> 2017-11-30 00:47:29,034 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/main - os.path.exists(socket_path)
>
> 2017-11-30 00:47:29,034 /usr/bin/ansible-connection.py False   # it is
> normal. If there is a socker handler file at first, make a persistent
> connection using that file, or create a file if it does not exist.
>
> 2017-11-30 00:47:29,035 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/main - pid
>
> 2017-11-30 00:47:29,035 /usr/bin/ansible-connection.py 29658
>
> 2017-11-30 00:47:29,035 /usr/bin/ansible-connection.py 29658
>
> 2017-11-30 00:47:29,036 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/main - pid
>
> 2017-11-30 00:47:29,036 /usr/bin/ansible-connection.py 0
>
> 2017-11-30 00:47:29,036 /usr/bin/ansible-connection.py 0
>
> 2017-11-30 00:47:29,036 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/main - make socket file
>
> 2017-11-30 00:47:29,036 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/Server/__init__ - socket_path
>
> 2017-11-30 00:47:29,036 /usr/bin/ansible-connection.py
> /home/docker/.ansible/pc/7d194f7854
>
> 2017-11-30 00:47:29,036 p=29655 u=docker |  creating new control socket
> for host 192.168.0.150:22 as user nsroot
>
> 2017-11-30 00:47:29,037 p=29655 u=docker |  control socket path is
> /home/docker/.ansible/pc/7d194f7854
>
> 2017-11-30 00:47:29,037 p=29655 u=docker |  current working directory is
> /home/docker/exec-ansible-code/template
>
> 2017-11-30 00:47:29,037 p=29655 u=docker |  using connection plugin
> network_cli
>
> 2017-11-30 00:47:29,037 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/Server/__init__ - play_context.connection
>
> 2017-11-30 00:47:29,037 /usr/bin/ansible-connection.py network_cli
>
> 2017-11-30 00:47:29,037 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/Server/__init__ - play_context
>
> 2017-11-30 00:47:29,037 /usr/bin/ansible-connection.py
> <ansible.playbook.play_context.PlayContext object at 0x7fdbb380bc90>
>
> 2017-11-30 00:47:29,037 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/Server/__init__ - sys.stdin
>
> 2017-11-30 00:47:29,037 /usr/bin/ansible-connection.py <open file
> '<stdin>', mode 'r' at 0x7fdbb636d0c0>
>
> 2017-11-30 00:47:29,056 plugins/connection/paramiko_ssh.py
> plugins/connection/paramiko_ssh.py
>
> 2017-11-30 00:47:29,058 plugins/connection/network_cli.py
> plugins/connection/network_cli.py
>
> 2017-11-30 00:47:29,066 paramiko.transport starting thread (client mode):
> 0xb3963cd0L
>
> 2017-11-30 00:47:29,070 paramiko.transport Connected (version 2.0, client
> OpenSSH_6.1-FIPS_hpn13v11)
>
> 2017-11-30 00:47:29,071 paramiko.transport kex
> algos:['ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521',
> 'diffie-hellman-group-exchange-sha256',
> 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1',
> 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client
> encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256',
> 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc',
> 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-...@lysator.liu.se']
> server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256',
> 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc',
> 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-...@lysator.liu.se']
> client mac:['hmac-md5', 'hmac-sha1', 'umac...@openssh.com',
> 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-ripemd160', '
> hmac-ripemd...@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server
> mac:['hmac-md5', 'hmac-sha1', 'umac...@openssh.com', 'hmac-sha2-256',
> 'hmac-sha2-512', 'hmac-ripemd160', 'hmac-ripemd...@openssh.com',
> 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', 'z...@openssh.com']
> server compress:['none', 'z...@openssh.com'] client lang:[''] server
> lang:[''] kex follows?False
>
> 2017-11-30 00:47:29,071 paramiko.transport Ciphers agreed:
> local=aes128-ctr, remote=aes128-ctr
>
> 2017-11-30 00:47:29,071 paramiko.transport using kex
> diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local
> aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1;
> compression: local none, remote none
>
> /usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141:
> FutureWarning: CTR mode needs counter parameter, not IV
>
>   self._cipher = factory.new(key, *args, **kwargs)
>
>
>
> # When you see the log, you will be connected to the device.
>
>
>
> 2017-11-30 00:47:29,177 paramiko.transport Switch to new keys ...
>
> 2017-11-30 00:47:29,278 paramiko.transport userauth is OK
>
> 2017-11-30 00:47:29,279 paramiko.transport Auth banner:
> ###############################################################################
>
> #
> #
>
> #        WARNING: Access to this system is for authorized users
> only          #
>
> #         Disconnect IMMEDIATELY if you are not an authorized
> user!           #
>
> #
> #
>
>
> ###############################################################################
>
>
>
>
>
> 2017-11-30 00:47:29,279 paramiko.transport Authentication (password)
> successful!
>
> 2017-11-30 00:47:29,286 p=29655 u=docker |  ssh connection done, setting
> terminal
>
> 2017-11-30 00:47:29,286 paramiko.transport [chan 1] Max packet in: 34816
> bytes
>
> 2017-11-30 00:47:29,286 paramiko.transport [chan 1] Max packet out: 32768
> bytes
>
> 2017-11-30 00:47:29,286 paramiko.transport Secsh channel 1 opened.
>
> 2017-11-30 00:47:29,287 paramiko.transport [chan 1] Sesch channel 1
> request ok
>
> 2017-11-30 00:47:29,288 paramiko.transport [chan 1] Sesch channel 1
> request ok
>
> 2017-11-30 00:47:29,291 p=29655 u=docker |  loaded terminal plugin for
> network_os kos
>
> 2017-11-30 00:47:29,293 p=29655 u=docker |  loaded cliconf plugin for
> network_os kos
>
> 2017-11-30 00:47:39,056 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/_do_it - stdout
>
> 2017-11-30 00:47:39,057 plugins/connection/persistent.py
>
> 2017-11-30 00:47:39,057 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/_do_it - stderr
>
> 2017-11-30 00:47:39,057 plugins/connection/persistent.py Traceback (most
> recent call last):
>
>   File "/usr/bin/ansible-connection", line 438, in <module>
>
>     main()
>
>   File "/usr/bin/ansible-connection", line 393, in main
>
>     raise AnsibleConnectionFailure('timeout waiting for local socket',
> pc.remote_addr)
>
> ansible.errors.AnsibleConnectionFailure: timeout waiting for local socket
>
>
>
> #I get an error because the local socket or file does not exist.
>
>
>
> The error appears to have been in
> '/home/docker/exec-ansible-code/template/test2.yml': line 14, column 13,
> but may
>
> be elsewhere in the file depending on the exact syntax problem.
>
>
>
> The offending line appears to be:
>
>
>
>       password: nsroot
>
>       host: 192.168.0.150
>
>             ^ here
>
>
>
>
>
> 2017-11-30 00:47:39,057 plugins/connection/persistent.py
> plugins/connection/persistent.py/Connection/run - match
>
> 2017-11-30 00:47:39,057 plugins/connection/persistent.py None
>
> 2017-11-30 00:47:39,057 action-kos_command action/kos_command.py -
> socket_path
>
> 2017-11-30 00:47:39,057 action-kos_command None
>
> 2017-11-30 00:47:39,057 action/kos_config.py plugins/action/
> kos_config.py/run - result
>
> 2017-11-30 00:47:39,057 action/kos_config.py {'msg': 'unable to open
> shell. Please see:
> https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell',
> 'failed': True}
>
> 2017-11-30 00:47:39,060 p=29645 u=docker |  fatal: [127.0.0.1]: FAILED! =>
> {"changed": false, "failed": true, "msg": "unable to open shell. Please
> see:
> https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell
> "}
>
> 2017-11-30 00:47:39,061 p=29645 u=docker |          to retry, use: --limit
> @/home/docker/exec-ansible-code/template/test2.retry
>
>
>
> 2017-11-30 00:47:39,061 p=29645 u=docker |  PLAY RECAP
> ***********************************************************************
>
> 2017-11-30 00:47:39,061 p=29645 u=docker |  127.0.0.1                  :
> ok=0    changed=0    unreachable=0    failed=1
>
> 2017-11-30 00:47:39,358 p=29655 u=docker |  failed to create control
> socket for host 192.168.0.150
>
> 2017-11-30 00:47:39,359 p=29655 u=docker |  Traceback (most recent call
> last):
>
>   File "/usr/bin/ansible-connection", line 352, in main
>
>     server = Server(socket_path, pc) # this is error point
>
>   File "/usr/bin/ansible-connection", line 133, in __init__
>
>     self.connection._connect()
>
>   File
> "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py",
> line 148, in _connect
>
>     self.receive()
>
>   File
> "/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py",
> line 185, in receive
>
>     data = self._shell.recv(256)
>
>   File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 619,
> in recv
>
>     raise socket.timeout()
>
> timeout
>
>
>
> 2017-11-30 00:47:39,359 /usr/bin/ansible-connection.py /usr/bin/
> ansible-connection.py/main - rc
>
> 2017-11-30 00:47:39,359 /usr/bin/ansible-connection.py 1
>
>
>
>
> Thank you for your precious time. ( Please give a hand me.. T.T)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-devel+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to