An Ansible kernel for Jupyter
Project description
# Ansible Jupyter Kernel

The Ansible [Jupyter](http://jupyter.readthedocs.io/en/latest/) Kernel adds a kernel backend for Jupyter to interface directly with Ansible and construct plays and tasks and execute them on the fly.
## Demo
[](https://vimeo.com/279049946 "Run Ansible Tasks from Jupyter Notebook - Click to Watch!")
## Table of Contents
* [Installation](#installation)
* [From pypi](#from-pypi)
* [From a local checkout](#from-a-local-checkout)
* [Usage](#usage)
* [Using the cells](#using-the-cells)
* [Examples](#examples)
* [Using the development environment](#using-the-development-environment)
## Installation:
`ansible-kernel` is available to be installed from pypi but you can also install it locally. The setup package itself will register the kernel
with `Jupyter` automatically.
### From pypi
pip install ansible-kernel
### From a local checkout
pip install -e .
## Usage
### Local install
```
jupyter notebook
# In the notebook interface, select Ansible from the 'New' menu
```
### Container
docker run -p 8888:8888 benthomasson/ansible-jupyter-kernel:v0.4
Then copy the URL from the output into your browser:
http://localhost:8888/?token=ABCD1234
## Using the Cells
Normally `Ansible` brings together various components in different files and locations to launch a playbook and performs automation tasks. For this
`jupyter` interface you need to provide this information in cells by denoting what the cell contains and then finally writing your tasks that will make
use of them. There are [Examples](#examples) available to help you, in this section we'll go over the currently supported cell types.
In order to denote what the cell contains you should prefix it with a pound/hash symbol (#) and the type as listed here as the first line as shown in the examples
below.
#### #inventory
The inventory that your tasks will use
```
#inventory
[all]
ahost ansible_connection=local
anotherhost examplevar=val
```
#### #play
This represents the opening block of a typical `Ansible` play
```
#play
name: Hello World
hosts: all
gather_facts: false
```
#### #task
This is the default cell type if no type is given for the first line
```
#task
debug:
```
```
#task
shell: cat /tmp/afile
register: output
```
#### #host_vars
This takes an argument that represents the hostname. Variables
defined in this file will be available in the tasks for that host.
```
#host_vars Host1
hostname: host1
```
#### #group_vars
This takes an argument that represents the group name. Variables
defined in this file will be available in the tasks for hosts in that
group.
```
#group_vars BranchOfficeX
gateway: 192.168.1.254
```
#### #vars
This takes an argument that represents the filename for use in later cells
```
#vars example_vars
message: hello vars
```
```
#play
name: hello world
hosts: localhost
gather_facts: false
vars_files:
- example_vars
```
#### #template
This takes an argument in order to create a templated file that can be used in later cells
```
#template hello.j2
{{ message }}
```
```
#task
template:
src: hello.j2
dest: /tmp/hello
```
#### #ansible.cfg
Provides overrides typically found in ansible.cfg
```
#ansible.cfg
[defaults]
host_key_checking=False
```
### Examples
You can find various [example notebooks in the repository](https://github.com/ansible/ansible-jupyter-kernel/tree/master/notebooks)
## Using the development environment
It's possible to use whatever python development process you feel comfortable with. The repository itself includes mechanisms for
using [pipenv](https://github.com/pypa/pipenv)
```
pipenv install
...
pipenv shell
```

The Ansible [Jupyter](http://jupyter.readthedocs.io/en/latest/) Kernel adds a kernel backend for Jupyter to interface directly with Ansible and construct plays and tasks and execute them on the fly.
## Demo
[](https://vimeo.com/279049946 "Run Ansible Tasks from Jupyter Notebook - Click to Watch!")
## Table of Contents
* [Installation](#installation)
* [From pypi](#from-pypi)
* [From a local checkout](#from-a-local-checkout)
* [Usage](#usage)
* [Using the cells](#using-the-cells)
* [Examples](#examples)
* [Using the development environment](#using-the-development-environment)
## Installation:
`ansible-kernel` is available to be installed from pypi but you can also install it locally. The setup package itself will register the kernel
with `Jupyter` automatically.
### From pypi
pip install ansible-kernel
### From a local checkout
pip install -e .
## Usage
### Local install
```
jupyter notebook
# In the notebook interface, select Ansible from the 'New' menu
```
### Container
docker run -p 8888:8888 benthomasson/ansible-jupyter-kernel:v0.4
Then copy the URL from the output into your browser:
http://localhost:8888/?token=ABCD1234
## Using the Cells
Normally `Ansible` brings together various components in different files and locations to launch a playbook and performs automation tasks. For this
`jupyter` interface you need to provide this information in cells by denoting what the cell contains and then finally writing your tasks that will make
use of them. There are [Examples](#examples) available to help you, in this section we'll go over the currently supported cell types.
In order to denote what the cell contains you should prefix it with a pound/hash symbol (#) and the type as listed here as the first line as shown in the examples
below.
#### #inventory
The inventory that your tasks will use
```
#inventory
[all]
ahost ansible_connection=local
anotherhost examplevar=val
```
#### #play
This represents the opening block of a typical `Ansible` play
```
#play
name: Hello World
hosts: all
gather_facts: false
```
#### #task
This is the default cell type if no type is given for the first line
```
#task
debug:
```
```
#task
shell: cat /tmp/afile
register: output
```
#### #host_vars
This takes an argument that represents the hostname. Variables
defined in this file will be available in the tasks for that host.
```
#host_vars Host1
hostname: host1
```
#### #group_vars
This takes an argument that represents the group name. Variables
defined in this file will be available in the tasks for hosts in that
group.
```
#group_vars BranchOfficeX
gateway: 192.168.1.254
```
#### #vars
This takes an argument that represents the filename for use in later cells
```
#vars example_vars
message: hello vars
```
```
#play
name: hello world
hosts: localhost
gather_facts: false
vars_files:
- example_vars
```
#### #template
This takes an argument in order to create a templated file that can be used in later cells
```
#template hello.j2
{{ message }}
```
```
#task
template:
src: hello.j2
dest: /tmp/hello
```
#### #ansible.cfg
Provides overrides typically found in ansible.cfg
```
#ansible.cfg
[defaults]
host_key_checking=False
```
### Examples
You can find various [example notebooks in the repository](https://github.com/ansible/ansible-jupyter-kernel/tree/master/notebooks)
## Using the development environment
It's possible to use whatever python development process you feel comfortable with. The repository itself includes mechanisms for
using [pipenv](https://github.com/pypa/pipenv)
```
pipenv install
...
pipenv shell
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ansible-kernel-0.4.2.tar.gz
(88.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ansible-kernel-0.4.2.tar.gz.
File metadata
- Download URL: ansible-kernel-0.4.2.tar.gz
- Upload date:
- Size: 88.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87eb28eff03d46ddae31c298b776b0631ec02dd1a03bd6dd69c2d95750c2dcc2
|
|
| MD5 |
00749a339e3b5cd1cf3b1f4029203b63
|
|
| BLAKE2b-256 |
e86d6738729ca6dff60cc3bee312f6a69491f2c6b69fa3824752c67fa47c77bf
|
File details
Details for the file ansible_kernel-0.4.2-py2.py3-none-any.whl.
File metadata
- Download URL: ansible_kernel-0.4.2-py2.py3-none-any.whl
- Upload date:
- Size: 97.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4199c66750a48cbd577198122d525bf6d283cd1411c793785854cfbd19360c9
|
|
| MD5 |
95ddbe8128b43e2be96dfe5602438cc3
|
|
| BLAKE2b-256 |
3aa306163ca89fba828f45c513472f20183f4dcd64a51cd26b7c88379a281283
|