No description
  • Python 50.7%
  • Jupyter Notebook 46.5%
  • Smarty 1.1%
  • Dockerfile 1.1%
  • Makefile 0.5%
  • Other 0.1%
Find a file
2022-02-11 10:18:23 -05:00
.github/ISSUE_TEMPLATE Update issue templates 2018-07-30 07:19:23 -04:00
ansible_kernel Bumps version to 1.0.0 2022-02-11 10:00:23 -05:00
docs Adds quick demo 2018-07-09 09:17:47 -04:00
notebooks Updates jupyter widgets example 2018-12-10 15:55:00 -05:00
openshift Replace CentOS with Fedora for OpenShift 2018-12-07 13:22:37 -05:00
tests Adds test and updates example 2018-11-30 09:37:13 -05:00
.flake8 flake8 2018-08-17 12:20:40 -04:00
.gitignore Adds notebooks as tests 2018-06-27 08:00:45 -04:00
.travis.yml Update travis 2018-08-17 12:12:52 -04:00
CHANGELOG.md Bumps version to 1.0.0 2022-02-11 10:00:23 -05:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2018-07-05 12:12:09 -04:00
CONTRIBUTING.md Doc updates for 0.4 2018-07-05 14:51:29 -04:00
Dockerfile Bumps version to 1.0.0 2022-02-11 10:00:23 -05:00
Dockerfile.dev Bumps version to 1.0.0 2022-02-11 10:00:23 -05:00
LICENSE.md Add license file 2018-06-19 16:34:07 -04:00
Makefile Changes centos to fedora in docker build 2018-12-12 11:01:27 -05:00
MANIFEST.in Correct MANIFEST.in syntax 2019-02-24 23:41:36 +01:00
Pipfile Bump pyyaml due to CVE-2017-18342 2019-01-09 15:30:07 -05:00
ProjectProposal.md Update project proposal 2018-07-12 12:12:52 -04:00
PULL_REQUEST_TEMPLATE.md Create PULL_REQUEST_TEMPLATE.md 2018-07-19 15:27:11 -04:00
README.md travis-ci.com 2018-12-19 13:52:22 +00:00
RELEASE.md Add release process 2019-01-09 15:30:07 -05:00
ROADMAP.md Bump version to 0.9.0 2018-12-12 12:56:28 -05:00
setup.cfg Filling out README and expanding the setup utility 2018-06-27 12:41:47 -04:00
setup.py Fixes setup for pypi 2022-02-11 10:18:23 -05:00

Ansible Jupyter Kernel

Build Status Binder

Example Jupyter Usage

The Ansible Jupyter Kernel adds a kernel backend for Jupyter to interface directly with Ansible and construct plays and tasks and execute them on the fly.

Demo

Demo

Table of Contents

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
python -m ansible_kernel.install

From a local checkout

pip install -e .
python -m ansible_kernel.install

For Anaconda/Miniconda

pip install ansible-kernel
python -m ansible_kernel.install --sys-prefix

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

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 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

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

pipenv install
...
pipenv shell