Closed BoPeng closed 3 years ago
I believe you are talking about the ansible kernel here.
First, I want to point out that you can work with this kernel using magics %expand
, %capture
etc, as explained here. At first glance I feel that %expand
should be good enough for a majority of the cases.
Then, if you would like to use magic %get
for this kernel, you will indeed need a language module. What underlying language that Ansible uses? If it uses Python as I understood from this notebook, you should be able to do something like %use Ansible --kernel ansible --language Python3
, and I can add ansible as supported kernel in the language definition of sos-python
so there is no need for a separate language module.
If Ansible is using its own language (the key here is that it has a definition of "variable" and related types and rules), you can define a language module following the documentation here. Basically you can copy any existing language module to get a "frame", try to understand how language module works, and modify it for Ansible. You can host the module in your organization/account, or I can create a frame in vatlab
and give you write permission to the repo. In either case, feel free to let me know if you have any question.
Just tried, ansible cannot use Python3 as the underlying language directly because it cannot run statements such as import
directly.
Cannot even get ansible kernel to work:
$ jupyter notebook
[I 08:21:37.674 NotebookApp] Loading IPython parallel extension
[I 08:21:38.633 NotebookApp] JupyterLab extension loaded from /Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/jupyterlab
[I 08:21:38.633 NotebookApp] JupyterLab application directory is /Users/bpeng1/anaconda3/envs/sos/share/jupyter/lab
[I 08:21:38.635 NotebookApp] Serving notebooks from local directory: /Users/bpeng1/sos
[I 08:21:38.635 NotebookApp] The Jupyter Notebook is running at:
[I 08:21:38.635 NotebookApp] http://localhost:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689
[I 08:21:38.635 NotebookApp] or http://127.0.0.1:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689
[I 08:21:38.635 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:21:38.667 NotebookApp]
To access the notebook, open this file in a browser:
file:///Users/bpeng1/Library/Jupyter/runtime/nbserver-50230-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689
or http://127.0.0.1:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689
[W 08:21:39.163 NotebookApp] 404 GET /api/kernels/45d4de77-9dae-4847-a854-52404cee283f/channels?session_id=1d3f6684862b496a8680c80faa5a2833 (::1): Kernel does not exist: 45d4de77-9dae-4847-a854-52404cee283f
[W 08:21:39.890 NotebookApp] 404 GET /api/kernels/45d4de77-9dae-4847-a854-52404cee283f/channels?session_id=1d3f6684862b496a8680c80faa5a2833 (::1) 818.63ms referer=None
[W 08:21:42.632 NotebookApp] 404 GET /api/kernels/9601eac9-6daa-499b-a702-f03b4dbd88e3/channels?session_id=6708523d2b1f45e183c57fa259bfd5ab (::1): Kernel does not exist: 9601eac9-6daa-499b-a702-f03b4dbd88e3
[W 08:21:42.633 NotebookApp] 404 GET /api/kernels/9601eac9-6daa-499b-a702-f03b4dbd88e3/channels?session_id=6708523d2b1f45e183c57fa259bfd5ab (::1) 2.63ms referer=None
[I 08:21:45.823 NotebookApp] Creating new notebook in
[I 08:21:49.627 NotebookApp] Kernel started: 96a3832b-9ecd-441c-ac23-eed6fb6234cf
/Users/bpeng1/anaconda3/envs/sos/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/sos/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 08:21:56.428 NotebookApp] Replacing stale connection: 45d4de77-9dae-4847-a854-52404cee283f:1d3f6684862b496a8680c80faa5a2833
[W 08:22:22.318 NotebookApp] 404 GET /static/notebook/js/main.min.js.map (::1) 2.74ms referer=None
[W 08:22:49.639 NotebookApp] Timeout waiting for kernel_info reply from 96a3832b-9ecd-441c-ac23-eed6fb6234cf
[W 08:22:49.653 NotebookApp] Replacing stale connection: 9601eac9-6daa-499b-a702-f03b4dbd88e3:6708523d2b1f45e183c57fa259bfd5ab
[I 08:23:18.952 NotebookApp] Saving file at /Untitled.ipynb
[I 08:23:49.281 NotebookApp] Saving file at /Untitled2.ipynb
Cannot even get ansible kernel to work:
$ jupyter notebook [I 08:21:37.674 NotebookApp] Loading IPython parallel extension [I 08:21:38.633 NotebookApp] JupyterLab extension loaded from /Users/bpeng1/anaconda3/envs/sos/lib/python3.7/site-packages/jupyterlab [I 08:21:38.633 NotebookApp] JupyterLab application directory is /Users/bpeng1/anaconda3/envs/sos/share/jupyter/lab [I 08:21:38.635 NotebookApp] Serving notebooks from local directory: /Users/bpeng1/sos [I 08:21:38.635 NotebookApp] The Jupyter Notebook is running at: [I 08:21:38.635 NotebookApp] http://localhost:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689 [I 08:21:38.635 NotebookApp] or http://127.0.0.1:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689 [I 08:21:38.635 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 08:21:38.667 NotebookApp] To access the notebook, open this file in a browser: file:///Users/bpeng1/Library/Jupyter/runtime/nbserver-50230-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689 or http://127.0.0.1:8888/?token=e75d7088584d51e442632c7636d69d336d9715a317b10689 [W 08:21:39.163 NotebookApp] 404 GET /api/kernels/45d4de77-9dae-4847-a854-52404cee283f/channels?session_id=1d3f6684862b496a8680c80faa5a2833 (::1): Kernel does not exist: 45d4de77-9dae-4847-a854-52404cee283f [W 08:21:39.890 NotebookApp] 404 GET /api/kernels/45d4de77-9dae-4847-a854-52404cee283f/channels?session_id=1d3f6684862b496a8680c80faa5a2833 (::1) 818.63ms referer=None [W 08:21:42.632 NotebookApp] 404 GET /api/kernels/9601eac9-6daa-499b-a702-f03b4dbd88e3/channels?session_id=6708523d2b1f45e183c57fa259bfd5ab (::1): Kernel does not exist: 9601eac9-6daa-499b-a702-f03b4dbd88e3 [W 08:21:42.633 NotebookApp] 404 GET /api/kernels/9601eac9-6daa-499b-a702-f03b4dbd88e3/channels?session_id=6708523d2b1f45e183c57fa259bfd5ab (::1) 2.63ms referer=None [I 08:21:45.823 NotebookApp] Creating new notebook in [I 08:21:49.627 NotebookApp] Kernel started: 96a3832b-9ecd-441c-ac23-eed6fb6234cf /Users/bpeng1/anaconda3/envs/sos/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/sos/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 08:21:56.428 NotebookApp] Replacing stale connection: 45d4de77-9dae-4847-a854-52404cee283f:1d3f6684862b496a8680c80faa5a2833 [W 08:22:22.318 NotebookApp] 404 GET /static/notebook/js/main.min.js.map (::1) 2.74ms referer=None [W 08:22:49.639 NotebookApp] Timeout waiting for kernel_info reply from 96a3832b-9ecd-441c-ac23-eed6fb6234cf [W 08:22:49.653 NotebookApp] Replacing stale connection: 9601eac9-6daa-499b-a702-f03b4dbd88e3:6708523d2b1f45e183c57fa259bfd5ab [I 08:23:18.952 NotebookApp] Saving file at /Untitled.ipynb [I 08:23:49.281 NotebookApp] Saving file at /Untitled2.ipynb
I am not facing any issues in running the Ansible kernel.
Did you check compatibility with python 3.7 on macosx? I created 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
Did you check compatibility with python 3.7 on macosx? I created 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
No, we use everything on Ubuntu.
The ansible kernel website does not mention anything like linux-only.
I am seeing the below text, I guess it is using Python2.7:
/home/ubuntu/.local/lib/python2.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/ubuntu/.local/lib/python2.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.
submitted a bug to upstream: https://github.com/ansible/ansible-jupyter-kernel/issues/84
https://github.com/ansible/ansible-jupyter-kernel/issues/84
Seems that Ansible kernel is no longer maintained (no commits and bug fix for two years). I will re-open this ticket after the aforementioned ticket from upstream is addressed.