News for hackers. Stuff that matters.
Re:Show HN: Ansible Kernel – Run Ansible Tasks and Plays wit... by jarpineh on Wednesday July 18, 2018 @02:24PM (#17560849)
I have been making Jupyter notebook for managing our container environment. Some work is still only possible through Ansible, so I've been wondering how to integrate that. Well, I need not wonder no more!

This looks very promising:

* auto completion!

* integrated documentation!

* exporting Ansible YAML!

I didn't yet have change to play with this, so I just note the ways I see Jupyter can be good fit for Ansible. You can try each step and see it working before moving to next one. There doesn't seem to be support yet for richer results view nor Jupyter Widgets, but imagine looking at actual error messages and result views instead of JSON as text. Getting and setting parameters for playbooks could be done using external data sources instead of hand-crafting inventories and config files. You could use same approach as Ara [1] and trace execution of tasks.

I assume you can run Ansible kernel from JupyterLab instance, so you can do file management and use terminal right on the machine you're running Ansible commands. Also, I'd imagine connecting with Jupyter Console (formerly IPython) to same kernel state as notebook is running with is possible here as well. This provides Terminal goodness alongside browser's visuals.

[1] Ara: http://ara.readthedocs.io/en/latest/

Re:Show HN: Ansible Kernel – Run Ansible Tasks and Plays wit... by import_awesome on Wednesday July 18, 2018 @02:57PM (#17561117)
Re:Show HN: Ansible Kernel – Run Ansible Tasks and Plays wit... by jarpineh on Wednesday July 18, 2018 @03:56PM (#17561585)
Hi, and thank you. It works well. Example play books already contain the basics I'd need for my playbooks.

Could you perhaps elaborate how the kernel directs Ansible?

Also, is there any difference between local and remote Ansible runs?

Re:Show HN: Ansible Kernel – Run Ansible Tasks and Plays wit... by import_awesome on Wednesday July 18, 2018 @04:27PM (#17561792)
Ansible Kernel calls ansible-playbook on a specially constructed playbook. Ansible Kernel constructs a playbook with a two tasks in it: 1. wait for the kernel and 2. include tasks from a file that does not exist yet. When you enter a #task cell we write that included file and then tell the wait task to proceed. The included file contains the #task cell contents, a wait task, and another include task. This continues until you stop the kernel, the playbook dies on an error, or you enter a #play cell. On a #play cell ansible kernel throws away the old playbook and make a new one with the new arguments. The exported playbook just contains the content on the page (without the wait/include tasks) and should work with ansible-playbook normally.
Re:Show HN: Ansible Kernel – Run Ansible Tasks and Plays wit... by jarpineh on Thursday July 19, 2018 @06:13AM (#17565040)
This does sound like Ansible does not make it easy to control it from pure Python. It looks an ingenious way to get around it.

I came across this Python wrapper around Ansible yesterday: http://suitable.readthedocs.io/en/latest/ Official docs declare themselves deprecated...

Anyway, I'll have to start testing this soon. Thank you so much for making it!

Re:Show HN: Ansible Kernel – Run Ansible Tasks and Plays wit... by import_awesome on Thursday July 19, 2018 @09:25AM (#17566012)
You're welcome. I hope that you find it useful.