ansible / ansible-jupyter-kernel

Jupyter Notebook Kernel for running Ansible Tasks and Playbooks
Other
534 stars 62 forks source link

Compatibility with MacOSX and python 3.7 #84

Closed BoPeng closed 4 years ago

BoPeng commented 5 years ago

Describe the bug ansible kernel hangs under MacOSX and python 3.7.

To Reproduce Create a fresh conda environent, and ansible kernel does not work.

$ conda create -n ansible python=3.7
$ pip install ansible-kernel
$ python -m ansible_kernel.install
$ jupyter notebook
[W 11:50:09.718 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 11:50:09.720 NotebookApp] The port 8888 is already in use, trying another port.
[I 11:50:09.720 NotebookApp] The port 8889 is already in use, trying another port.
[I 11:50:09.728 NotebookApp] Serving notebooks from local directory: /Users/bpeng1
[I 11:50:09.728 NotebookApp] The Jupyter Notebook is running at:
[I 11:50:09.728 NotebookApp] http://bcbm-bpeng.mdanderson.edu:8890/
[I 11:50:09.728 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 11:50:14.887 NotebookApp] Creating new notebook in
[I 11:50:15.881 NotebookApp] Kernel started: cae4aef6-83f6-4f08-89ec-1d9e3262f363
/Users/bpeng1/anaconda3/envs/ansible/lib/python3.7/site-packages/ansible_kernel/modules.py:4: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  modules = yaml.load(f.read())
/Users/bpeng1/anaconda3/envs/ansible/lib/python3.7/site-packages/ansible_kernel/module_args.py:4: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  module_args = yaml.load(f.read())
[W 11:51:15.951 NotebookApp] Timeout waiting for kernel_info reply from cae4aef6-83f6-4f08-89ec-1d9e3262f363
[I 11:52:16.453 NotebookApp] Saving file at /Untitled.ipynb
^C[I 11:52:52.442 NotebookApp] interrupted

Screenshots image

Desktop (please complete the following information):

BoPeng commented 5 years ago

Does not work under linux either

(ansible) [bpeng1@localhost ~]$ conda create -n ansible python=3.7
(ansible) [bpeng1@localhost ~]$ pip install ansible-kernel
(ansible) [bpeng1@localhost ~]$ python -m ansible_kernel.install
Installing IPython kernel spec
/home/bpeng1/anaconda3/envs/ansible/lib/python3.7/site-packages/ansible_kernel/install.py:26: DeprecationWarning: replace is ignored. Installing a kernelspec always replaces an existing installation
  td, 'ansible', user=user, replace=True, prefix=prefix)
(ansible) [bpeng1@localhost ~]$ jupyter notebook
[I 13:42:10.274 NotebookApp] Writing notebook server cookie secret to /home/bpeng1/.local/share/jupyter/runtime/notebook_cookie_secret
[I 13:42:10.488 NotebookApp] Serving notebooks from local directory: /home/bpeng1
[I 13:42:10.489 NotebookApp] The Jupyter Notebook is running at:
[I 13:42:10.489 NotebookApp] http://localhost:8888/?token=af98f5e99043d650af86725dc1026c330f86648182068cd0
[I 13:42:10.489 NotebookApp]  or http://127.0.0.1:8888/?token=af98f5e99043d650af86725dc1026c330f86648182068cd0
[I 13:42:10.489 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:42:10.576 NotebookApp] 

    To access the notebook, open this file in a browser:
        file:///home/bpeng1/.local/share/jupyter/runtime/nbserver-12886-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=af98f5e99043d650af86725dc1026c330f86648182068cd0
     or http://127.0.0.1:8888/?token=af98f5e99043d650af86725dc1026c330f86648182068cd0
[I 13:42:19.291 NotebookApp] Creating new notebook in 
[I 13:42:19.301 NotebookApp] Writing notebook-signing key to /home/bpeng1/.local/share/jupyter/notebook_secret
[I 13:42:20.396 NotebookApp] Kernel started: e82625dc-8646-4993-aa1f-bcb1df6d15dc
/home/bpeng1/anaconda3/envs/ansible/lib/python3.7/site-packages/ansible_kernel/modules.py:4: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  modules = yaml.load(f.read())
/home/bpeng1/anaconda3/envs/ansible/lib/python3.7/site-packages/ansible_kernel/module_args.py:4: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  module_args = yaml.load(f.read())
Traceback (most recent call last):
  File "/home/bpeng1/anaconda3/envs/ansible/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/bpeng1/anaconda3/envs/ansible/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/bpeng1/anaconda3/envs/ansible/lib/python3.7/site-packages/ansible_kernel/__main__.py", line 6, in <module>
    IPKernelApp.launch_instance(kernel_class=AnsibleKernel)
veksh commented 4 years ago

Same with macos 11.2 and python 3.5; ansible_kenel.log looks like

[2020-09-03 16:40:24,204] DEBUG [asyncio.__init__:65] Using selector: KqueueSelector
[2020-09-03 16:40:24,209] DEBUG [asyncio.__init__:65] Using selector: KqueueSelector
[2020-09-03 16:40:24,211] DEBUG [ansible_kernel.kernel.__init__:179] session <class 'jupyter_client.session.Session'> <jupyter_client.session.Session object at 0x10d6ffc18>
[2020-09-03 16:40:24,211] DEBUG [ansible_kernel.kernel.__init__:180] iopub_socket <class 'ipykernel.iostream.BackgroundSocket'> <ipykernel.iostream.BackgroundSocket object at 0x10d705ac8>
[2020-09-03 16:40:24,281] DEBUG [ansible_kernel.kernel.__init__:228] /var/folders/0m/ls08dfrx6sz0xw1jnqglswb80000gn/T/ansible_kernel_playbookj5sur5i5
[2020-09-03 16:40:24,284] INFO [ansible_kernel.kernel.do_inventory:566] inventory set to [all]
localhost ansible_connection=local

[2020-09-03 16:40:24,286] INFO [ansible_kernel.kernel.is_ansible_alive:1137] NOT STARTED
[2020-09-03 16:40:24,286] DEBUG [asyncio.__init__:65] Using selector: KqueueSelector
[2020-09-03 16:40:24,287] INFO [ansible_kernel.kernel.start:114] thread.start
[2020-09-03 16:40:24,288] DEBUG [ansible_kernel.kernel.process_widgets:728] widget_vars_file /var/folders/0m/ls08dfrx6sz0xw1jnqglswb80000gn/T/ansible_kernel_playbookj5sur5i5/project/widget_vars.yml
[2020-09-03 16:40:24,288] INFO [ansible_kernel.kernel.start_helper:257] Started helper
[2020-09-03 16:40:24,289] DEBUG [ansible_kernel.kernel.start_helper:275] vault_password? None
[2020-09-03 16:40:24,290] INFO [ansible_kernel.kernel.start_helper:287] Wrote ansible.cfg
[2020-09-03 16:40:24,291] DEBUG [ansible_kernel.kernel.do_execute_play:632] code_data {'name': 'default', 'gather_facts': False, 'hosts': 'localhost'}
[2020-09-03 16:40:24,291] DEBUG [ansible_kernel.kernel.do_execute_play:633] code_data type: <class 'dict'>
[2020-09-03 16:40:24,296] DEBUG [ansible_kernel.kernel.do_execute_play:659] - gather_facts: false
  hosts: localhost
  name: default
  roles:
  - ansible_kernel_helpers
  tasks:
  - pause_for_kernel:
      host: 127.0.0.1
      port: 49351
      task_num: -1
  - include_vars:
      file: widget_vars.yml
  - include_tasks: next_task0.yml

[2020-09-03 16:40:24,299] DEBUG [ansible_kernel.kernel.send_multipart:86] send_multipart [b'<IDS|MSG>', b'd32b8aa6d42c7b50d3b035431abfd05e6b03f6186b9fa450d8d20669f9fbe0e5', b'{"username":"alex","msg_id":"4c5d768f-5e740e9f92ee358a12a5d0e5_0","session":"4c5d768f-5e740e9f92ee358a12a5d0e5","version":"5.3","date":"2020-09-03T13:40:24.299514Z","msg_type":"stream"}', b'{}', b'{}', b'{"text":"\\n","name":"stdout"}'] () {'copy': True}
[2020-09-03 16:40:24,299] DEBUG [ansible_kernel.kernel.send_multipart:89] result None
[2020-09-03 16:40:24,300] DEBUG [ansible_kernel.kernel.send_multipart:1233] send_multipart 6 [b'<IDS|MSG>', b'd32b8aa6d42c7b50d3b035431abfd05e6b03f6186b9fa450d8d20669f9fbe0e5', b'{"username":"alex","msg_id":"4c5d768f-5e740e9f92ee358a12a5d0e5_0","session":"4c5d768f-5e740e9f92ee358a12a5d0e5","version":"5.3","date":"2020-09-03T13:40:24.299514Z","msg_type":"stream"}', b'{}', b'{}', b'{"text":"\\n","name":"stdout"}'] () {'copy': True}
[2020-09-03 16:40:24,300] DEBUG [ansible_kernel.kernel.send_multipart:89] result None
[2020-09-03 16:40:24,300] INFO [ansible_kernel.kernel.start_ansible_playbook:681] runner starting
[2020-09-03 16:40:24,302] INFO [ansible_kernel.kernel.start_ansible_playbook:692] runner started
[2020-09-03 16:40:24,302] INFO [ansible_kernel.kernel.start_ansible_playbook:693] Runner status: starting
[2020-09-03 16:40:24,302] INFO [ansible_kernel.kernel.start_ansible_playbook:695] In runner loop
[2020-09-03 16:40:24,303] INFO [ansible_kernel.kernel.start_ansible_playbook:698] getting message 49351
[2020-09-03 16:40:25,307] INFO [ansible_kernel.kernel.start_ansible_playbook:701] Queue Empty!
[2020-09-03 16:40:25,307] INFO [ansible_kernel.kernel.start_ansible_playbook:695] In runner loop
[2020-09-03 16:40:25,307] INFO [ansible_kernel.kernel.start_ansible_playbook:698] getting message 49351
[2020-09-03 16:40:26,310] INFO [ansible_kernel.kernel.start_ansible_playbook:701] Queue Empty!
<endless repetition>