Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SPHINXPROJ = ansible-runner
|
||||
SOURCEDIR = .
|
||||
BUILDDIR = _build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
@@ -0,0 +1,30 @@
|
||||
ansible\_runner.callbacks package
|
||||
=================================
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ansible\_runner.callbacks.awx\_display module
|
||||
---------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.callbacks.awx_display
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.callbacks.minimal module
|
||||
----------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.callbacks.minimal
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ansible_runner.callbacks
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,54 @@
|
||||
ansible\_runner.display\_callback package
|
||||
=========================================
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ansible\_runner.display\_callback.cleanup module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.cleanup
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.display module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.display
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.events module
|
||||
-----------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.events
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.minimal module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.minimal
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.module module
|
||||
-----------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.module
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,70 @@
|
||||
ansible\_runner package
|
||||
=======================
|
||||
|
||||
Subpackages
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
|
||||
ansible_runner.callbacks
|
||||
ansible_runner.display_callback
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ansible\_runner.exceptions module
|
||||
---------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.exceptions
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.interface module
|
||||
--------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.interface
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.loader module
|
||||
-----------------------------
|
||||
|
||||
.. automodule:: ansible_runner.loader
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.runner module
|
||||
-----------------------------
|
||||
|
||||
.. automodule:: ansible_runner.runner
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.runner\_config module
|
||||
-------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.runner_config
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.utils module
|
||||
----------------------------
|
||||
|
||||
.. automodule:: ansible_runner.utils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ansible_runner
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file does only contain a selection of the most common options. For a
|
||||
# full list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('../'))
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath('./'))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'ansible-runner'
|
||||
copyright = '2018, Red Hat Ansible'
|
||||
author = 'Red Hat Ansible'
|
||||
|
||||
# The short X.Y version
|
||||
version = ''
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '2.0.0'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.doctest',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.viewcode',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path .
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# The default sidebars (for documents that don't match any pattern) are
|
||||
# defined by theme itself. Builtin themes are using these templates by
|
||||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'ansible-runnerdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'ansible-runner.tex', 'ansible-runner Documentation',
|
||||
'Red Hat Ansible', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'ansible-runner', 'ansible-runner Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'ansible-runner', 'ansible-runner Documentation',
|
||||
author, 'ansible-runner', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
||||
# -- Options for todo extension ----------------------------------------------
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
@@ -0,0 +1,49 @@
|
||||
.. _container:
|
||||
|
||||
Using Runner as a container interface to Ansible
|
||||
================================================
|
||||
|
||||
The design of **Ansible Runner** makes it especially suitable for controlling the execution of **Ansible** from within a container for single-purpose
|
||||
automation workflows. A reference container image definition is `provided <https://github.com/ansible/ansible-runner/blob/master/Dockerfile>`_ and
|
||||
is also published to `DockerHub <https://hub.docker.com/r/ansible/ansible-runner/>`_ you can try it out for yourself
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ docker run --rm -e RUNNER_PLAYBOOK=test.yml ansible/ansible-runner:latest
|
||||
Unable to find image 'ansible/ansible-runner:latest' locally
|
||||
latest: Pulling from ansible/ansible-runner
|
||||
[...]
|
||||
PLAY [all] *********************************************************************
|
||||
|
||||
TASK [Gathering Facts] *********************************************************
|
||||
ok: [localhost]
|
||||
|
||||
TASK [debug] *******************************************************************
|
||||
ok: [localhost] => {
|
||||
"msg": "Test!"
|
||||
}
|
||||
|
||||
PLAY RECAP *********************************************************************
|
||||
localhost : ok=2 changed=0 unreachable=0 failed=0
|
||||
|
||||
|
||||
The reference container image is purposefully light-weight and only containing the dependencies necessary to run ``ansible-runner`` itself. It's
|
||||
intended to be overridden.
|
||||
|
||||
Overriding the reference container image
|
||||
----------------------------------------
|
||||
|
||||
**TODO**
|
||||
|
||||
Gathering output from the reference container image
|
||||
---------------------------------------------------
|
||||
|
||||
**TODO**
|
||||
|
||||
Changing the console output to emit raw events
|
||||
----------------------------------------------
|
||||
|
||||
This can be useful when directing task-level event data to an external system by means of the container's console output.
|
||||
|
||||
See :ref:`outputjson`
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
.. _execution_environments:
|
||||
|
||||
Using Runner with Execution Environmnets
|
||||
========================================
|
||||
|
||||
**Execution Environments** are meant to be a consistent, reproducible, portable,
|
||||
and sharable method to run Ansible Automation jobs in the exact same way on
|
||||
your laptop as they are executed in `Ansible AWX <https://github.com/ansible/awx/`_.
|
||||
This aids in the development of automation jobs and Ansible Content that is
|
||||
meant to be run in **Ansible AWX**, `Ansible Tower <https://www.ansible.com/products/tower>`_,
|
||||
or via `Red Hat Ansible Automation Platform <https://www.ansible.com/products/automation-platform>`_
|
||||
in a predictable way.
|
||||
|
||||
More specifically, the term **Execution Environments** within the context of
|
||||
**Ansible Runner** refers to the container runtime execution of **Ansible** via
|
||||
**Ansible Runner** within an `OCI Compliant Container Runtime
|
||||
<https://github.com/opencontainers/runtime-spec>`_ using an `OCI Compliant
|
||||
Container Image <https://github.com/opencontainers/image-spec/>`_ that
|
||||
appropriately bundles `Ansible Base <https://github.com/ansible/ansible>`_,
|
||||
`Ansible Collection Content <https://github.com/ansible-collections/overview>`_,
|
||||
and the runtime dependencies required to support these contents. The base
|
||||
image is the `Red Hat Enterprise Linux Universal Base Image
|
||||
<https://developers.redhat.com/products/rhel/ubi>`_ and the build tooling
|
||||
provided by `Ansible Builder <https://github.com/ansible/ansible-builder>`_
|
||||
aids in the creation of these images.
|
||||
|
||||
All aspects of running **Ansible Runner** in standalone mode (see: :ref:`standalone`)
|
||||
are true here with the exception that the process isolation is inherently a
|
||||
container runtime (`podman <https://podman.io/>`_ by default).
|
||||
|
||||
Emulating the Ansible CLI
|
||||
-------------------------
|
||||
|
||||
As previously mentioned, a primary goal of adding the Execution Environment CLI
|
||||
interface is to aid in the creation of Ansible Automation jobs and content. The
|
||||
approach here is to make it as similar as possible to the way **Ansible** users
|
||||
are accustomed to using Ansible today. There are two subcommands, ``adhoc`` and
|
||||
``playbook`` that have been added to accommodate this. The ``adhoc`` subcommand
|
||||
to ``ansible-runner`` is synonymous with ``ansible`` and the ``playbook``
|
||||
subcommand to ``ansible-runner`` is synonymous with ``ansible-playbook``.
|
||||
Examples are below.
|
||||
|
||||
Running Ansible adhoc
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
An example invocation using the ``ping`` module and ``localhost`` as target::
|
||||
|
||||
$ ansible-runner adhoc localhost -m ping
|
||||
|
||||
Something to note here is that implicit ``localhost`` in this context is a containerized instantiation of an Ansible Execution Environment and as such you will not get Ansible Facts about your system if using the ``setup`` module.
|
||||
|
||||
Running Ansible ansible-playbook
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
An example invocation using the ``demo.yml`` playbook and ``inventory.ini`` inventory file::
|
||||
|
||||
$ ansible-runner playbook demo.yml -i inventory.ini
|
||||
|
||||
Something to note here is that implicit ``localhost`` in this context is a containerized instantiation of an Ansible Execution Environment and as such you will not get Ansible Facts about your system if using ``gather_facts: true`` and targeting ``localhost`` in your playbook without explicit host definition in your inventory.
|
||||
|
||||
Notes and Considerations
|
||||
------------------------
|
||||
|
||||
There are some differences between using Ansible Runner and running Ansible directly from the
|
||||
command line that have to do with configuration, content locality, and secret data.
|
||||
|
||||
Secrets
|
||||
^^^^^^^
|
||||
|
||||
Typically with Ansible you are able to provide secret data via a series of
|
||||
mechanisms, many of which are pluggable and configurable. When using
|
||||
Ansible Runner, however, certain considerations need to be made; these are analogous to
|
||||
how Ansible AWX and Tower manage this information.
|
||||
|
||||
See :ref:`inputdir` for more information
|
||||
|
||||
Container Names
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Like all ansible-runner jobs, each job has an identifier associated with it
|
||||
which is also the name of the artifacts subfolder where results are saved to.
|
||||
When a container for job isolation is launched, it will be given a name
|
||||
of ``ansible_runner_<job identifier>``. Some characters from the job
|
||||
identifier may be replaced with underscores for compatibility with
|
||||
names that Podman and Docker allow.
|
||||
|
||||
This name is used internally if a command needs to be ran against the container
|
||||
at a later time (e.g., to stop the container when the job is canceled).
|
||||
|
||||
~/.ssh/ symlinks
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
In order to make the ``adhoc`` and ``playbook`` container execution of Ansible
|
||||
easier, Ansible Runner will automatically bind mount your local ssh agent
|
||||
UNIX-domain socket (``SSH_AUTH_SOCK``) into the container runtime. However, this
|
||||
does not work if files in your ``~/.ssh/`` directory happen to be symlinked to
|
||||
another directory that is also not mounted into the container runtime. Ansible
|
||||
Runner ``adhoc`` and ``playbook`` subcommands provide the ``--container-volume-mount``
|
||||
option to address this, among other things.
|
||||
|
||||
Here is an example of an ssh config file that is a symlink:
|
||||
|
||||
::
|
||||
|
||||
$ $ ls -l ~/.ssh/config
|
||||
lrwxrwxrwx. 1 myuser myuser 34 Jul 15 19:27 /home/myuser/.ssh/config -> /home/myuser/dotfiles/ssh_config
|
||||
|
||||
$ ansible-runner playbook \
|
||||
--container-volume-mount /home/myuser/dotfiles/:/home/myuser/dotfiles/ \
|
||||
my_playbook.yml -i my_inventory.ini
|
||||
@@ -0,0 +1,78 @@
|
||||
.. _externalintf:
|
||||
|
||||
Sending Runner Status and Events to External Systems
|
||||
====================================================
|
||||
|
||||
**Runner** can store event and status data locally for retrieval, it can also emit this information via callbacks provided to the module interface.
|
||||
|
||||
Alternatively **Runner** can be configured to send events to an external system via installable plugins, there are currently two available
|
||||
|
||||
.. _plugineventstructure:
|
||||
|
||||
Event Structure
|
||||
---------------
|
||||
|
||||
There are two types of events that are emitted via plugins:
|
||||
|
||||
* status events:
|
||||
|
||||
These are sent whenever Runner's status changes (see :ref:`runnerstatushandler`) for example::
|
||||
|
||||
{"status": "running", "runner_ident": "XXXX" }
|
||||
|
||||
* ansible events:
|
||||
|
||||
These are sent during playbook execution for every event received from **Ansible** (see :ref:`Playbook and Host Events<artifactevents>`) for example::
|
||||
|
||||
{"runner_ident": "XXXX", <rest of event structure }
|
||||
|
||||
.. _httpemitterplugin:
|
||||
|
||||
HTTP Status/Event Emitter Plugin
|
||||
--------------------------------
|
||||
|
||||
This sends status and event data to a URL in the form of json encoded POST requests.
|
||||
|
||||
This plugin is available from the `ansible-runner-http github repo <https://github.com/ansible/ansible-runner-http>`_ and is also available to be installed from
|
||||
pip::
|
||||
|
||||
$ pip install ansible-runner-http
|
||||
|
||||
In order to configure it, you can provide details in the Runner Settings file (see :ref:`runnersettings`):
|
||||
|
||||
* `runner_http_url`: The url to receive the ``POST``
|
||||
* `runner_http_headers`: Headers to send along with the request.
|
||||
|
||||
The plugin also supports unix file-based sockets with:
|
||||
|
||||
* `runner_http_url`: The path to the unix socket
|
||||
* `runner_http_path`: The path that will be included as part of the request to the socket
|
||||
|
||||
Some of these settings are also available as environment variables:
|
||||
|
||||
* RUNNER_HTTP_URL
|
||||
* RUNNER_HTTP_PATH
|
||||
|
||||
.. _zmqemitterplugin:
|
||||
|
||||
ZeroMQ Status/Event Emitter Plugin
|
||||
----------------------------------
|
||||
|
||||
TODO
|
||||
|
||||
Writing your own Plugin
|
||||
-----------------------
|
||||
|
||||
In order to write your own plugin interface and have it be picked up and used by **Runner** there are a few things that you'll need to do.
|
||||
|
||||
* Declare the module as a Runner entrypoint in your setup file
|
||||
(`ansible-runner-http has a good example of this <https://github.com/ansible/ansible-runner-http/blob/master/setup.py>`_)::
|
||||
|
||||
entry_points=('ansible_runner.plugins': 'modname = your_python_package_name'),
|
||||
|
||||
* Implement the ``status_handler()`` and ``event_handler()`` functions at the top of your package, for example see
|
||||
`ansible-runner-http events.py <https://github.com/ansible/ansible-runner-http/blob/master/ansible_runner_http/events.py>`_ and the ``__init__``
|
||||
import `at the top of the module package <https://github.com/ansible/ansible-runner-http/blob/master/ansible_runner_http/__init__.py>`_
|
||||
|
||||
After installing this, **Runner** will see the plugin and invoke the functions when status and events are sent. If there are any errors in your plugin
|
||||
they will be raised immediately and **Runner** will fail.
|
||||
@@ -0,0 +1,55 @@
|
||||
.. ansible-runner documentation master file, created by
|
||||
sphinx-quickstart on Tue May 1 10:47:37 2018.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Ansible Runner
|
||||
==============
|
||||
|
||||
Ansible Runner is a tool and python library that helps when interfacing with Ansible directly or as part of another system
|
||||
whether that be through a container image interface, as a standalone tool, or as a Python module that can be imported. The goal
|
||||
is to provide a stable and consistent interface abstraction to Ansible. This allows **Ansible** to be embedded into other systems that don't
|
||||
want to manage the complexities of the interface on their own (such as CI/CD platforms, Jenkins, or other automated tooling).
|
||||
|
||||
**Ansible Runner** represents the modularization of the part of `Ansible Tower/AWX <https://github.com/ansible/awx>`_ that is responsible
|
||||
for running ``ansible`` and ``ansible-playbook`` tasks and gathers the output from it. It does this by presenting a common interface that doesn't
|
||||
change, even as **Ansible** itself grows and evolves.
|
||||
|
||||
Part of what makes this tooling useful is that it can gather its inputs in a flexible way (See :ref:`intro`:). It also has a system for storing the
|
||||
output (stdout) and artifacts (host-level event data, fact data, etc) of the playbook run.
|
||||
|
||||
There are 3 primary ways of interacting with **Runner**
|
||||
|
||||
* A standalone command line tool (``ansible-runner``) that can be started in the foreground or run in the background asynchronously
|
||||
* A reference container image that can be used as a base for your own images and will work as a standalone container or running in
|
||||
Openshift or Kubernetes
|
||||
* A python module - library interface
|
||||
|
||||
**Ansible Runner** can also be configured to send status and event data to other systems using a plugin interface, see :ref:`externalintf`.
|
||||
|
||||
Examples of this could include:
|
||||
|
||||
* Sending status to Ansible Tower/AWX
|
||||
* Sending events to an external logging service
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
intro
|
||||
install
|
||||
external_interface
|
||||
standalone
|
||||
python_interface
|
||||
execution_environments
|
||||
container
|
||||
remote_jobs
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
@@ -0,0 +1,88 @@
|
||||
.. _install:
|
||||
|
||||
Installing Ansible Runner
|
||||
=========================
|
||||
|
||||
Ansible Runner is provided from several different locations depending on how you want to use it.
|
||||
|
||||
Using pip
|
||||
---------
|
||||
|
||||
Python 2.7+ and 3.6+ are supported and installable via pip::
|
||||
|
||||
$ pip install ansible-runner
|
||||
|
||||
|
||||
Fedora
|
||||
------
|
||||
|
||||
To install from the latest Fedora sources::
|
||||
|
||||
$ dnf install python-ansible-runner
|
||||
|
||||
Debian
|
||||
------
|
||||
|
||||
Add an ansible-runner repository::
|
||||
|
||||
$ apt-get update
|
||||
$ echo 'deb https://releases.ansible.com/ansible-runner/deb/ <trusty|xenial|stretch> main' > /etc/apt/sources.list.d/ansible.list
|
||||
|
||||
Add a key::
|
||||
|
||||
$ apt-key adv --keyserver keyserver.ubuntu.com --recv 3DD29021
|
||||
|
||||
Install the package::
|
||||
|
||||
$ apt-get update
|
||||
$ apt-get install ansible-runner
|
||||
|
||||
|
||||
From source
|
||||
-----------
|
||||
|
||||
Ansible Runner uses `python-poetry <https://python-poetry.org/`_ for
|
||||
development and dependency management, once that is installed performed the
|
||||
following steps.
|
||||
|
||||
Check out the source code from `github <https://github.com/ansible/ansible-runner>`_::
|
||||
|
||||
$ git clone git://github.com/ansible/ansible-runner
|
||||
|
||||
Or download from the `releases page <https://github.com/ansible/ansible-runner/releases>`_
|
||||
|
||||
Then install::
|
||||
|
||||
$ poetry install
|
||||
|
||||
.. _builddist:
|
||||
|
||||
Build the distribution
|
||||
----------------------
|
||||
|
||||
To produce an installable ``wheel`` file::
|
||||
|
||||
make dist
|
||||
|
||||
To produce a distribution tarball::
|
||||
|
||||
make sdist
|
||||
|
||||
.. _buildcontimg:
|
||||
|
||||
Building the base container image
|
||||
---------------------------------
|
||||
|
||||
Make sure the ``wheel`` distribution is built (see :ref:`builddist`) and run::
|
||||
|
||||
make image
|
||||
|
||||
Building the RPM
|
||||
----------------
|
||||
|
||||
The RPM build uses a container image to bootstrap the environment in order to produce the RPM. Make sure you have docker
|
||||
installed and proceed with::
|
||||
|
||||
make rpm
|
||||
|
||||
.. include:: ../CHANGES.rst
|
||||
+395
@@ -0,0 +1,395 @@
|
||||
.. _intro:
|
||||
|
||||
Introduction to Ansible Runner
|
||||
==============================
|
||||
|
||||
**Runner** is intended to be most useful as part of automation and tooling that needs to invoke Ansible and consume its results.
|
||||
Most of the parameterization of the **Ansible** command line is also available on the **Runner** command line but **Runner** also
|
||||
can rely on an input interface that is mapped onto a directory structure, an example of which can be seen in `the source tree <https://github.com/ansible/ansible-runner/tree/devel/demo>`_.
|
||||
|
||||
Further sections in this document refer to the configuration and layout of that hierarchy. This isn't the only way to interface with **Runner**
|
||||
itself. The Python module interface allows supplying these details as direct module parameters in many forms, and the command line interface allows
|
||||
supplying them directly as arguments, mimicking the behavior of ``ansible-playbook``. Having the directory structure **does** allow gathering the inputs
|
||||
from elsewhere and preparing them for consumption by **Runner**, then the tooling can come along and inspect the results after the run.
|
||||
|
||||
This is best seen in the way Ansible **AWX** uses **Runner** where most of the content comes from the database (and other content-management components) but
|
||||
ultimately needs to be brought together in a single place when launching the **Ansible** task.
|
||||
|
||||
.. _inputdir:
|
||||
|
||||
Runner Input Directory Hierarchy
|
||||
--------------------------------
|
||||
|
||||
This directory contains all necessary inputs. Here's a view of the `demo directory <https://github.com/ansible/ansible-runner/tree/devel/demo>`_ showing
|
||||
an active configuration.
|
||||
|
||||
Note that not everything is required. Defaults will be used or values will be omitted if they are not provided.
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
.
|
||||
├── env
|
||||
│ ├── envvars
|
||||
│ ├── extravars
|
||||
│ ├── passwords
|
||||
│ ├── cmdline
|
||||
│ ├── settings
|
||||
│ └── ssh_key
|
||||
├── inventory
|
||||
│ └── hosts
|
||||
└── project
|
||||
├── test.yml
|
||||
└── roles
|
||||
└── testrole
|
||||
├── defaults
|
||||
├── handlers
|
||||
├── meta
|
||||
├── README.md
|
||||
├── tasks
|
||||
├── tests
|
||||
└── vars
|
||||
|
||||
The ``env`` directory
|
||||
---------------------
|
||||
|
||||
The **env** directory contains settings and sensitive files that inform certain aspects of the invocation of the **Ansible** process, an example of which can
|
||||
be found in `the demo env directory <https://github.com/ansible/ansible-runner/tree/devel/demo/env>`_. Each of these files can also be represented by a named
|
||||
pipe providing a bit of an extra layer of security. The formatting and expectation of these files differs slightly depending on what they are representing.
|
||||
|
||||
``env/envvars``
|
||||
---------------
|
||||
|
||||
.. note::
|
||||
|
||||
For an example see `the demo envvars <https://github.com/ansible/ansible-runner/blob/devel/demo/env/envvars>`_.
|
||||
|
||||
**Ansible Runner** will inherit the environment of the launching shell (or container, or system itself). This file (which can be in json or yaml format) represents
|
||||
the environment variables that will be added to the environment at run-time::
|
||||
|
||||
---
|
||||
TESTVAR: exampleval
|
||||
|
||||
``env/extravars``
|
||||
-----------------
|
||||
|
||||
.. note::
|
||||
|
||||
For an example see `the demo extravars <https://github.com/ansible/ansible-runner/blob/devel/demo/env/extravars>`_.
|
||||
|
||||
**Ansible Runner** gathers the extra vars provided here and supplies them to the **Ansible Process** itself. This file can be in either json or yaml format::
|
||||
|
||||
---
|
||||
ansible_connection: local
|
||||
test: val
|
||||
|
||||
``env/passwords``
|
||||
-----------------
|
||||
|
||||
.. note::
|
||||
|
||||
For an example see `the demo passwords <https://github.com/ansible/ansible-runner/blob/devel/demo/env/passwords>`_.
|
||||
|
||||
.. warning::
|
||||
|
||||
We expect this interface to change/simplify in the future but will guarantee backwards compatibility. The goal is for the user of **Runner** to not
|
||||
have to worry about the format of certain prompts emitted from **Ansible** itself. In particular, vault passwords need to become more flexible.
|
||||
|
||||
**Ansible** itself is set up to emit passwords to certain prompts, these prompts can be requested (``-k`` for example to prompt for the connection password).
|
||||
Likewise, prompts can be emitted via `vars_prompt <https://docs.ansible.com/ansible/latest/user_guide/playbooks_prompts.html>`_ and also
|
||||
`Ansible Vault <https://docs.ansible.com/ansible/2.5/user_guide/vault.html#vault-ids-and-multiple-vault-passwords>`_.
|
||||
|
||||
In order for **Runner** to respond with the correct password, it needs to be able to match the prompt and provide the correct password. This is currently supported
|
||||
by providing a yaml or json formatted file with a regular expression and a value to emit, for example::
|
||||
|
||||
---
|
||||
"^SSH password:\\s*?$": "some_password"
|
||||
"^BECOME password.*:\\s*?$": "become_password"
|
||||
|
||||
``env/cmdline``
|
||||
---------------
|
||||
|
||||
.. warning::
|
||||
|
||||
Current **Ansible Runner** does not validate the command line arguments passed using this method so it is up to the playbook writer to provide a valid set of options
|
||||
The command line options provided by this method are lower priority than the ones set by **Ansible Runner**. For instance, this will not override `inventory` or `limit` values.
|
||||
|
||||
**Ansible Runner** gathers command line options provided here as a string and supplies them to the **Ansible Process** itself. This file should contain the arguments to be added, for example::
|
||||
|
||||
--tags one,two --skip-tags three -u ansible --become
|
||||
|
||||
``env/ssh_key``
|
||||
---------------
|
||||
|
||||
.. note::
|
||||
|
||||
Currently only a single ssh key can be provided via this mechanism but this is set to `change soon <https://github.com/ansible/ansible-runner/issues/51>`_.
|
||||
|
||||
This file should contain the ssh private key used to connect to the host(s). **Runner** detects when a private key is provided and will wrap the call to
|
||||
**Ansible** in ssh-agent.
|
||||
|
||||
.. _runnersettings:
|
||||
|
||||
``env/settings`` - Settings for Runner itself
|
||||
---------------------------------------------
|
||||
|
||||
The **settings** file is a little different than the other files provided in this section in that its contents are meant to control **Runner** directly.
|
||||
|
||||
* ``idle_timeout``: ``600`` If no output is detected from ansible in this number of seconds the execution will be terminated.
|
||||
* ``job_timeout``: ``3600`` The maximum amount of time to allow the job to run for, exceeding this and the execution will be terminated.
|
||||
* ``pexpect_timeout``: ``10`` Number of seconds for the internal pexpect command to wait to block on input before continuing
|
||||
* ``pexpect_use_poll``: ``True`` Use ``poll()`` function for communication with child processes instead of ``select()``. ``select()`` is used when the value is set to ``False``. ``select()`` has a known limitation of using only up to 1024 file descriptors.
|
||||
|
||||
* ``suppress_ansible_output``: ``False`` Allow output from ansible to not be printed to the screen
|
||||
* ``fact_cache``: ``'fact_cache'`` The directory relative to ``artifacts`` where ``jsonfile`` fact caching will be stored. Defaults to ``fact_cache``. This is ignored if ``fact_cache_type`` is different than ``jsonfile``.
|
||||
* ``fact_cache_type``: ``'jsonfile'`` The type of fact cache to use. Defaults to ``jsonfile``.
|
||||
|
||||
Process Isolation Settings for Runner
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The process isolation settings are meant to control the process isolation feature of **Runner**.
|
||||
|
||||
* ``process_isolation``: ``False`` Enable limiting what directories on the filesystem the playbook run has access to.
|
||||
* ``process_isolation_executable``: ``bwrap`` Path to the executable that will be used to provide filesystem isolation.
|
||||
* ``process_isolation_path``: ``/tmp`` Path that an isolated playbook run will use for staging.
|
||||
* ``process_isolation_hide_paths``: ``None`` Path or list of paths on the system that should be hidden from the playbook run.
|
||||
* ``process_isolation_show_paths``: ``None`` Path or list of paths on the system that should be exposed to the playbook run.
|
||||
* ``process_isolation_ro_paths``: ``None`` Path or list of paths on the system that should be exposed to the playbook run as read-only.
|
||||
|
||||
Container-based Execution
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``--containerized`` setting instructs **Ansible Runner** to execute **Ansible** tasks inside a container environment. A default execution environment is provided on Docker Hub at [ansible/ansible-runner](https://hub.docker.com/r/ansible/ansible-runner). Users also have the option of building their own container for executing playbooks, however.
|
||||
|
||||
To build an execution environment locally, run:
|
||||
|
||||
``docker build --rm=true -t custom-container -f Dockerfile .``
|
||||
|
||||
or, using `podman <https://podman.io/releases/>`_:
|
||||
|
||||
``podman build --rm=true -t custom-container -f Dockerfile .``
|
||||
|
||||
To run Ansible Runner with your custom container:
|
||||
|
||||
``ansible-runner run --container-image custom-container -p playbook.yml``
|
||||
|
||||
See ``ansible-runner -h`` for other container-related options.
|
||||
|
||||
Performance Data Collection Settings for Runner
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Runner** is capable of collecting performance data (namely cpu usage, memory usage, and pid count) during the execution of a playbook run.
|
||||
|
||||
Resource profiling is made possible by the use of control groups (often referred to simply as cgroups). When a process runs inside of a cgroup, the resources used by that specific process can be measured.
|
||||
|
||||
Before enabling Runner's resource profiling feature, users must create a cgroup that **Runner** can use. It is worth noting that only privileged users can create cgroups. The new cgroup should be associated with the same user (and related group) that will be invoking **Runner**. The following command accomplishes this on a RHEL system::
|
||||
|
||||
sudo yum install libcgroup-tools
|
||||
sudo cgcreate -a `whoami` -t `whoami` -g cpuacct,memory,pids:ansible-runner
|
||||
|
||||
In the above command, ``cpuacct``, ``memory``, and ``pids`` refer to kernel resource controllers, while ``ansible-runner`` refers to the name of the cgroup being created. More detailed information on the structure of cgroups can be found in the RHEL guide on `Managing, monitoring, and updating the kernel <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/setting-limits-for-applications_managing-monitoring-and-updating-the-kernel>`_
|
||||
|
||||
After a cgroup has been created, the following settings can be used to configure resource profiling. Note that ``resource_profiling_base_cgroup`` must match the name of the cgroup you create.
|
||||
|
||||
* ``resource_profiling``: ``False`` Enable performance data collection.
|
||||
* ``resource_profiling_base_cgroup``: ``ansible-runner`` Top-level cgroup used to measure playbook resource utilization.
|
||||
* ``resource_profiling_cpu_poll_interval``: ``0.25`` Polling interval in seconds for collecting cpu usage.
|
||||
* ``resource_profiling_memory_poll_interval``: ``0.25`` Polling interval in seconds for collecting memory usage.
|
||||
* ``resource_profiling_pid_poll_interval``: ``0.25`` Polling interval in seconds for measuring PID count.
|
||||
* ``resource_profiling_results_dir``: ``None`` Directory where resource utilization data will be written (if not specified, will be placed in the ``profiling_data`` folder under the private data directory).
|
||||
|
||||
Inventory
|
||||
---------
|
||||
|
||||
The **Runner** ``inventory`` location under the private data dir has the same expectations as inventory provided directly to ansible itself. It can
|
||||
be either a single file or script or a directory containing static inventory files or scripts. This inventory is automatically loaded and provided to
|
||||
**Ansible** when invoked and can be further overridden on the command line or via the ``ANSIBLE_INVENTORY`` environment variable to specify the hosts directly.
|
||||
Giving an absolute path for the inventory location is best practice, because relative paths are interpreted relative to the ``current working directory``
|
||||
which defaults to the ``project`` directory.
|
||||
|
||||
Project
|
||||
--------
|
||||
|
||||
The **Runner** ``project`` directory is the playbook root containing playbooks and roles that those playbooks can consume directly. This is also the
|
||||
directory that will be set as the ``current working directory`` when launching the **Ansible** process.
|
||||
|
||||
|
||||
Modules
|
||||
-------
|
||||
|
||||
**Runner** has the ability to execute modules directly using Ansible ad-hoc mode.
|
||||
|
||||
Roles
|
||||
-----
|
||||
|
||||
**Runner** has the ability to execute `Roles <https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html>`_ directly without first needing
|
||||
a playbook to reference them. This directory holds roles used for that. Behind the scenes, **Runner** will generate a playbook and invoke the ``Role``.
|
||||
|
||||
.. _artifactdir:
|
||||
|
||||
Runner Artifacts Directory Hierarchy
|
||||
------------------------------------
|
||||
|
||||
This directory will contain the results of **Runner** invocation grouped under an ``identifier`` directory. This identifier can be supplied to **Runner** directly
|
||||
and if not given, an identifier will be generated as a `UUID <https://docs.python.org/3/library/uuid.html#uuid.uuid4>`_. This is how the directory structure looks
|
||||
from the top level::
|
||||
|
||||
.
|
||||
├── artifacts
|
||||
│ └── identifier
|
||||
├── env
|
||||
├── inventory
|
||||
├── profiling_data
|
||||
├── project
|
||||
└── roles
|
||||
|
||||
The artifact directory itself contains a particular structure that provides a lot of extra detail from a running or previously-run invocation of Ansible/Runner::
|
||||
|
||||
.
|
||||
├── artifacts
|
||||
│ └── 37f639a3-1f4f-4acb-abee-ea1898013a25
|
||||
│ ├── fact_cache
|
||||
│ │ └── localhost
|
||||
│ ├── job_events
|
||||
│ │ ├── 1-34437b34-addd-45ae-819a-4d8c9711e191.json
|
||||
│ │ ├── 2-8c164553-8573-b1e0-76e1-000000000006.json
|
||||
│ │ ├── 3-8c164553-8573-b1e0-76e1-00000000000d.json
|
||||
│ │ ├── 4-f16be0cd-99e1-4568-a599-546ab80b2799.json
|
||||
│ │ ├── 5-8c164553-8573-b1e0-76e1-000000000008.json
|
||||
│ │ ├── 6-981fd563-ec25-45cb-84f6-e9dc4e6449cb.json
|
||||
│ │ └── 7-01c7090a-e202-4fb4-9ac7-079965729c86.json
|
||||
│ ├── rc
|
||||
│ ├── status
|
||||
│ └── stdout
|
||||
|
||||
|
||||
The **rc** file contains the actual return code from the **Ansible** process.
|
||||
|
||||
The **status** file contains one of three statuses suitable for displaying:
|
||||
|
||||
* success: The **Ansible** process finished successfully
|
||||
* failed: The **Ansible** process failed
|
||||
* timeout: The **Runner** timeout (see :ref:`runnersettings`)
|
||||
|
||||
The **stdout** file contains the actual stdout as it appears at that moment.
|
||||
|
||||
.. _artifactevents:
|
||||
|
||||
Runner Artifact Job Events (Host and Playbook Events)
|
||||
-----------------------------------------------------
|
||||
|
||||
**Runner** gathers the individual task and playbook events that are emitted as part of the **Ansible** run. This is extremely helpful if you don't want
|
||||
to process or read the stdout returned from **Ansible** as it contains much more detail and status than just the plain stdout.
|
||||
It does some of the heavy lifting of assigning order to the events and stores them in json format under the ``job_events`` artifact directory.
|
||||
It also takes it a step further than normal **Ansible** callback plugins in that it will store the ``stdout`` associated with the event alongside the raw
|
||||
event data (along with stdout line numbers). It also generates dummy events for stdout that didn't have corresponding host event data::
|
||||
|
||||
{
|
||||
"uuid": "8c164553-8573-b1e0-76e1-000000000008",
|
||||
"parent_uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
||||
"counter": 5,
|
||||
"stdout": "\r\nTASK [debug] *******************************************************************",
|
||||
"start_line": 5,
|
||||
"end_line": 7,
|
||||
"event": "playbook_on_task_start",
|
||||
"event_data": {
|
||||
"playbook": "test.yml",
|
||||
"playbook_uuid": "34437b34-addd-45ae-819a-4d8c9711e191",
|
||||
"play": "all",
|
||||
"play_uuid": "8c164553-8573-b1e0-76e1-000000000006",
|
||||
"play_pattern": "all",
|
||||
"task": "debug",
|
||||
"task_uuid": "8c164553-8573-b1e0-76e1-000000000008",
|
||||
"task_action": "debug",
|
||||
"task_path": "\/home\/mjones\/ansible\/ansible-runner\/demo\/project\/test.yml:3",
|
||||
"task_args": "msg=Test!",
|
||||
"name": "debug",
|
||||
"is_conditional": false,
|
||||
"pid": 10640
|
||||
},
|
||||
"pid": 10640,
|
||||
"created": "2018-06-07T14:54:58.410605"
|
||||
}
|
||||
|
||||
If the playbook runs to completion without getting killed, the last event will always be the ``stats`` event::
|
||||
|
||||
{
|
||||
"uuid": "01c7090a-e202-4fb4-9ac7-079965729c86",
|
||||
"counter": 7,
|
||||
"stdout": "\r\nPLAY RECAP *********************************************************************\r\n\u001b[0;32mlocalhost,\u001b[0m : \u001b[0;32mok=2 \u001b[0m changed=0 unreachable=0 failed=0 \r\n",
|
||||
"start_line": 10,
|
||||
"end_line": 14,
|
||||
"event": "playbook_on_stats",
|
||||
"event_data": {
|
||||
"playbook": "test.yml",
|
||||
"playbook_uuid": "34437b34-addd-45ae-819a-4d8c9711e191",
|
||||
"changed": {
|
||||
|
||||
},
|
||||
"dark": {
|
||||
|
||||
},
|
||||
"failures": {
|
||||
|
||||
},
|
||||
"ok": {
|
||||
"localhost,": 2
|
||||
},
|
||||
"processed": {
|
||||
"localhost,": 1
|
||||
},
|
||||
"skipped": {
|
||||
|
||||
},
|
||||
"artifact_data": {
|
||||
|
||||
},
|
||||
"pid": 10640
|
||||
},
|
||||
"pid": 10640,
|
||||
"created": "2018-06-07T14:54:58.424603"
|
||||
}
|
||||
|
||||
.. note::
|
||||
|
||||
The **Runner module interface** presents a programmatic interface to these events that allow getting the final status and performing host filtering of task events.
|
||||
|
||||
Runner Profiling Data Directory
|
||||
-------------------------------
|
||||
|
||||
If resource profiling is enabled for **Runner** the ``profiling_data`` directory will be populated with a set of files containing the profiling data::
|
||||
|
||||
.
|
||||
├── profiling_data
|
||||
│ ├── 0-34437b34-addd-45ae-819a-4d8c9711e191-cpu.json
|
||||
│ ├── 0-34437b34-addd-45ae-819a-4d8c9711e191-memory.json
|
||||
│ ├── 0-34437b34-addd-45ae-819a-4d8c9711e191-pids.json
|
||||
│ ├── 1-8c164553-8573-b1e0-76e1-000000000006-cpu.json
|
||||
│ ├── 1-8c164553-8573-b1e0-76e1-000000000006-memory.json
|
||||
│ └── 1-8c164553-8573-b1e0-76e1-000000000006-pids.json
|
||||
|
||||
Each file is in `JSON text format <https://tools.ietf.org/html/rfc7464#section-2.2>`_. Each line of the file will begin with a record separator (RS), continue with a JSON dictionary, and conclude with a line feed (LF) character. The following provides an example of what the resource files may look like. Note that that since the RS and LF are control characters, they are not actually printed below::
|
||||
|
||||
==> 0-525400c9-c704-29a6-4107-00000000000c-cpu.json <==
|
||||
{"timestamp": 1568977988.6844425, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 97.12799768097156}
|
||||
{"timestamp": 1568977988.9394386, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 94.17538298892688}
|
||||
{"timestamp": 1568977989.1901696, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 64.38272588006255}
|
||||
{"timestamp": 1568977989.4594045, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 83.77387744259856}
|
||||
|
||||
==> 0-525400c9-c704-29a6-4107-00000000000c-memory.json <==
|
||||
{"timestamp": 1568977988.4281094, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 36.21484375}
|
||||
{"timestamp": 1568977988.6842303, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 57.87109375}
|
||||
{"timestamp": 1568977988.939303, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 66.60546875}
|
||||
{"timestamp": 1568977989.1900482, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 71.4609375}
|
||||
{"timestamp": 1568977989.4592078, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 38.25390625}
|
||||
|
||||
==> 0-525400c9-c704-29a6-4107-00000000000c-pids.json <==
|
||||
{"timestamp": 1568977988.4284189, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 5}
|
||||
{"timestamp": 1568977988.6845856, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 6}
|
||||
{"timestamp": 1568977988.939547, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 8}
|
||||
{"timestamp": 1568977989.1902773, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 13}
|
||||
{"timestamp": 1568977989.4593227, "task_name": "Gathering Facts", "task_uuid": "525400c9-c704-29a6-4107-00000000000c", "value": 6}
|
||||
|
||||
* Resource profiling data is grouped by playbook task.
|
||||
* For each task, there will be three files, corresponding to cpu, memory and pid count data.
|
||||
* Each file contains a set of data points collected over the course of a playbook task.
|
||||
* If a task executes quickly and the polling rate for a given metric is large enough, it is possible that no profiling data may be collected during the task's execution. If this is the case, no data file will be created.
|
||||
@@ -0,0 +1,36 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=.
|
||||
set BUILDDIR=_build
|
||||
set SPHINXPROJ=ansible-runner
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
|
||||
:end
|
||||
popd
|
||||
@@ -0,0 +1,7 @@
|
||||
ansible_runner
|
||||
==============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
ansible_runner
|
||||
@@ -0,0 +1,141 @@
|
||||
.. _python_interface:
|
||||
|
||||
Using Runner as a Python Module Interface to Ansible
|
||||
====================================================
|
||||
|
||||
**Ansible Runner** is intended to provide a directly importable and usable API for interfacing with **Ansible** itself and exposes a few helper interfaces.
|
||||
|
||||
The modules center around the :class:`Runner <ansible_runner.runner.Runner>` object. The helper methods will return an instance of this object which provides an
|
||||
interface to the results of executing the **Ansible** command.
|
||||
|
||||
**Ansible Runner** itself is a wrapper around **Ansible** execution and so adds plugins and interfaces to the system in order to gather extra information and
|
||||
process/store it for use later.
|
||||
|
||||
Helper Interfaces
|
||||
-----------------
|
||||
|
||||
The helper :mod:`interfaces <ansible_runner.interface>` provides a quick way of supplying the recommended inputs in order to launch a **Runner** process. These interfaces also allow overriding and providing inputs beyond the scope of what the standalone or container interfaces
|
||||
support. You can see a full list of the inputs in the linked module documentation.
|
||||
|
||||
``run()`` helper function
|
||||
-------------------------
|
||||
|
||||
:meth:`ansible_runner.interface.run`
|
||||
|
||||
When called, this function will take the inputs (either provided as direct inputs to the function or from the :ref:`inputdir`), and execute **Ansible**. It will run in the
|
||||
foreground and return the :class:`Runner <ansible_runner.runner.Runner>` object when finished.
|
||||
|
||||
``run_async()`` helper function
|
||||
-------------------------------
|
||||
|
||||
:meth:`ansible_runner.interface.run_async`
|
||||
|
||||
Takes the same arguments as :meth:`ansible_runner.interface.run` but will launch **Ansible** asynchronously and return a tuple containing
|
||||
the ``thread`` object and a :class:`Runner <ansible_runner.runner.Runner>` object. The **Runner** object can be inspected during execution.
|
||||
|
||||
The ``Runner`` object
|
||||
---------------------
|
||||
|
||||
The :class:`Runner <ansible_runner.runner.Runner>` object is returned as part of the execution of **Ansible** itself. Since it wraps both execution and output
|
||||
it has some helper methods for inspecting the results. Other than the methods and indirect properties, the instance of the object itself contains two direct
|
||||
properties:
|
||||
|
||||
* ``rc`` will represent the actual return code of the **Ansible** process
|
||||
* ``status`` will represent the state and can be one of:
|
||||
* ``unstarted``: This is a very brief state where the Runner task has been created but hasn't actually started yet.
|
||||
* ``successful``: The ``ansible`` process finished successfully.
|
||||
* ``failed``: The ``ansible`` process failed.
|
||||
|
||||
``Runner.stdout``
|
||||
-----------------
|
||||
|
||||
The :class:`Runner <ansible_runner.runner.Runner>` object contains a property :attr:`ansible_runner.runner.Runner.stdout` which will return an open file
|
||||
handle containing the ``stdout`` of the **Ansible** process.
|
||||
|
||||
``Runner.events``
|
||||
-----------------
|
||||
|
||||
:attr:`ansible_runner.runner.Runner.events` is a ``generator`` that will return the :ref:`Playbook and Host Events<artifactevents>` as Python ``dict`` objects.
|
||||
|
||||
``Runner.stats``
|
||||
----------------
|
||||
|
||||
:attr:`ansible_runner.runner.Runner.stats` is a property that will return the final ``playbook stats`` event from **Ansible** in the form of a Python ``dict``
|
||||
|
||||
``Runner.host_events``
|
||||
----------------------
|
||||
:meth:`ansible_runner.runner.Runner.host_events` is a method that, given a hostname, will return a list of only **Ansible** event data executed on that Host.
|
||||
|
||||
``Runner.get_fact_cache``
|
||||
-------------------------
|
||||
|
||||
:meth:`ansible_runner.runner.Runner.get_fact_cache` is a method that, given a hostname, will return a dictionary containing the `Facts <https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variables-discovered-from-systems-facts>`_ stored for that host during execution.
|
||||
|
||||
``Runner.event_handler``
|
||||
------------------------
|
||||
|
||||
A function passed to `__init__` of :class:`Runner <ansible_runner.runner.Runner>`, this is invoked every time an Ansible event is received. You can use this to
|
||||
inspect/process/handle events as they come out of Ansible. This function should return `True` to keep the event, otherwise it will be discarded.
|
||||
|
||||
``Runner.cancel_callback``
|
||||
--------------------------
|
||||
|
||||
A function passed to ``__init__`` of :class:`Runner <ansible_runner.runner.Runner>`, and to the :meth:`ansible_runner.interface.run` interface functions.
|
||||
This function will be called for every iteration of the :meth:`ansible_runner.interface.run` event loop and should return `True`
|
||||
to inform **Runner** cancel and shutdown the **Ansible** process or `False` to allow it to continue.
|
||||
|
||||
``Runner.finished_callback``
|
||||
----------------------------
|
||||
|
||||
A function passed to ``__init__`` of :class:`Runner <ansible_runner.runner.Runner>`, and to the :meth:`ansible_runner.interface.run` interface functions.
|
||||
This function will be called immediately before the **Runner** event loop finishes once **Ansible** has been shut down.
|
||||
|
||||
.. _runnerstatushandler:
|
||||
|
||||
``Runner.status_handler``
|
||||
-------------------------
|
||||
|
||||
A function passed to ``__init__`` of :class:`Runner <ansible_runner.runner.Runner>` and to the :meth:`ansible_runner.interface.run` interface functions.
|
||||
This function will be called any time the ``status`` changes, expected values are:
|
||||
|
||||
* `starting`: Preparing to start but hasn't started running yet
|
||||
* `running`: The **Ansible** task is running
|
||||
* `canceled`: The task was manually canceled either via callback or the cli
|
||||
* `timeout`: The timeout configured in Runner Settings was reached (see :ref:`runnersettings`)
|
||||
* `failed`: The **Ansible** process failed
|
||||
|
||||
Usage examples
|
||||
--------------
|
||||
.. code-block:: python
|
||||
|
||||
import ansible_runner
|
||||
r = ansible_runner.run(private_data_dir='/tmp/demo', playbook='test.yml')
|
||||
print("{}: {}".format(r.status, r.rc))
|
||||
# successful: 0
|
||||
for each_host_event in r.events:
|
||||
print(each_host_event['event'])
|
||||
print("Final status:")
|
||||
print(r.stats)
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import ansible_runner
|
||||
r = ansible_runner.run(private_data_dir='/tmp/demo', host_pattern='localhost', module='shell', module_args='whoami')
|
||||
print("{}: {}".format(r.status, r.rc))
|
||||
# successful: 0
|
||||
for each_host_event in r.events:
|
||||
print(each_host_event['event'])
|
||||
print("Final status:")
|
||||
print(r.stats)
|
||||
|
||||
Providing custom behavior and inputs
|
||||
------------------------------------
|
||||
|
||||
**TODO**
|
||||
|
||||
The helper methods are just one possible entrypoint, extending the classes used by these helper methods can allow a lot more custom behavior and functionality.
|
||||
|
||||
Show:
|
||||
|
||||
* How :class:`Runner Config <ansible_runner.runner_config.RunnerConfig>` is used and how overriding the methods and behavior can work
|
||||
* Show how custom cancel and status callbacks can be supplied.
|
||||
@@ -0,0 +1,37 @@
|
||||
.. _remote_jobs:
|
||||
|
||||
Remote job execution
|
||||
====================
|
||||
|
||||
Ansible Runner supports the concept that a job run may be requested on one host but executed on another.
|
||||
This capability is primarily intended to be used by `Receptor <http://www.github.com/project-receptor/receptor>`_.
|
||||
|
||||
Support for this in Runner involves a three phase process.
|
||||
|
||||
- **Transmit**: Convert the job to a binary format that can be sent to the worker node.
|
||||
- **Worker**: Actually execute the job.
|
||||
- **Process**: Receive job results and process them.
|
||||
|
||||
The following command illustrates how the three phases work together::
|
||||
|
||||
$ ansible-runner transmit ./demo -p test.yml | ansible-runner worker | ansible-runner process ./demo
|
||||
|
||||
In this example, the `ansible-runner transmit` command is given a private data directory of `./demo` and told to select
|
||||
the `test.yml` playbook from it. Instead of executing the playbook as `ansible-runner run` would do, the data dir
|
||||
and command line parameters are converted to a compressed binary stream that is emitted as stdout. The `transmit`
|
||||
command generally takes the same command line parameters as the `run` command.
|
||||
|
||||
The `ansible-runner worker` command accepts this stream, runs the playbook, and generates a new compressed binary
|
||||
stream of the resulting job events and artifacts. The `worker` command takes no parameters.
|
||||
|
||||
The `ansible-runner process` command accepts the result stream from the worker, and fires all the normal callbacks
|
||||
and does job event processing. In the command above, this results in printing the playbook output and saving
|
||||
artifacts to the data dir. The `process` command takes a data dir as a parameter, to know where to save artifacts.
|
||||
|
||||
Python API
|
||||
----------
|
||||
|
||||
Python code importing Ansible Runner can make use of these facilities by setting the `streamer` parameter to
|
||||
`ansible_runner.interface.run`. This parameter can be set to `transmit`, `worker` or `process` to invoke
|
||||
each of the three stages. Other parameters are as normal in the CLI.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
ansible\_runner.callbacks package
|
||||
=================================
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ansible\_runner.callbacks.awx\_display module
|
||||
---------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.callbacks.awx_display
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.callbacks.minimal module
|
||||
----------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.callbacks.minimal
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ansible_runner.callbacks
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,54 @@
|
||||
ansible\_runner.display\_callback package
|
||||
=========================================
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ansible\_runner.display\_callback.cleanup module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.cleanup
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.display module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.display
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.events module
|
||||
-----------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.events
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.minimal module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.minimal
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.display\_callback.module module
|
||||
-----------------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback.module
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ansible_runner.display_callback
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,62 @@
|
||||
ansible\_runner package
|
||||
=======================
|
||||
|
||||
Subpackages
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
|
||||
ansible_runner.callbacks
|
||||
ansible_runner.display_callback
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ansible\_runner.exceptions module
|
||||
---------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.exceptions
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.interface module
|
||||
--------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.interface
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.runner module
|
||||
-----------------------------
|
||||
|
||||
.. automodule:: ansible_runner.runner
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.runner\_config module
|
||||
-------------------------------------
|
||||
|
||||
.. automodule:: ansible_runner.runner_config
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ansible\_runner.utils module
|
||||
----------------------------
|
||||
|
||||
.. automodule:: ansible_runner.utils
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ansible_runner
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
@@ -0,0 +1,7 @@
|
||||
ansible_runner
|
||||
==============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
ansible_runner
|
||||
@@ -0,0 +1,136 @@
|
||||
.. _standalone:
|
||||
|
||||
Using Runner as a standalone command line tool
|
||||
==============================================
|
||||
|
||||
The **Ansible Runner** command line tool can be used as a standard command line interface to **Ansible** itself but is primarily intended
|
||||
to fit into automation and pipeline workflows. Because of this, it has a bit of a different workflow than **Ansible** itself because you can select between a few different modes to launch the command.
|
||||
|
||||
While you can launch **Runner** and provide it all of the inputs as arguments to the command line (as you do with **Ansible** itself),
|
||||
there is another interface where inputs are gathered into a single location referred to in the command line parameters as ``private_data_dir``.
|
||||
(see :ref:`inputdir`)
|
||||
|
||||
To view the parameters accepted by ``ansible-runner``::
|
||||
|
||||
$ ansible-runner --help
|
||||
|
||||
An example invocation of the standalone ``ansible-runner`` utility::
|
||||
|
||||
$ ansible-runner -p playbook.yml run /tmp/private
|
||||
|
||||
Where playbook.yml is the playbook from the ``/tmp/private/projects`` directory, and ``run`` is the command mode you want to invoke **Runner** with
|
||||
|
||||
The different **commands** that runner accepts are:
|
||||
|
||||
* ``run`` starts ``ansible-runner`` in the foreground and waits until the underlying **Ansible** process completes before returning
|
||||
* ``start`` starts ``ansible-runner`` as a background daemon process and generates a pid file
|
||||
* ``stop`` terminates an ``ansible-runner`` process that was launched in the background with ``start``
|
||||
* ``is-alive`` checks the status of an ``ansible-runner`` process that was started in the background with ``start``
|
||||
* ``adhoc`` will run ad-hoc ``ansible`` commands inside a containerized Ansible Execution Environment
|
||||
* ``playbook`` will run ``ansible-playbook`` commands inside a containerized Ansible Execution Environment
|
||||
|
||||
While **Runner** is running it creates an ``artifacts`` directory (see :ref:`artifactdir`) regardless of what mode it was started
|
||||
in. The resulting output and status from **Ansible** will be located here. You can control the exact location underneath the ``artifacts`` directory
|
||||
with the ``-i IDENT`` argument to ``ansible-runner``, otherwise a random UUID will be generated.
|
||||
|
||||
Executing **Runner** in the foreground
|
||||
--------------------------------------
|
||||
|
||||
When launching **Runner** with the ``run`` command, as above, the program will stay in the foreground and you'll see output just as you expect from a normal
|
||||
**Ansible** process. **Runner** will still populate the ``artifacts`` directory, as mentioned in the previous section, to preserve the output and allow processing
|
||||
of the artifacts after exit.
|
||||
|
||||
Executing **Runner** in the background
|
||||
--------------------------------------
|
||||
|
||||
When launching **Runner** with the ``start`` command, the program will generate a pid file and move to the background. You can check its status with the
|
||||
``is-alive`` command, or terminate it with the ``stop`` command. You can find the stdout, status, and return code in the ``artifacts`` directory.
|
||||
|
||||
Running Playbooks
|
||||
-----------------
|
||||
|
||||
An example invocation using ``demo`` as private directory::
|
||||
|
||||
$ ansible-runner --playbook test.yml run demo
|
||||
|
||||
Running Modules Directly
|
||||
------------------------
|
||||
|
||||
An example invocating the ``debug`` module with ``demo`` as a private directory::
|
||||
|
||||
$ ansible-runner -m debug --hosts localhost -a msg=hello run demo
|
||||
|
||||
|
||||
Running Roles Directly
|
||||
----------------------
|
||||
|
||||
An example invocation using ``demo`` as private directory and ``localhost`` as target::
|
||||
|
||||
$ ansible-runner --role testrole --hosts localhost run demo
|
||||
|
||||
Ansible roles directory can be provided with ``--roles-path`` option. Role variables can be passed with ``--role-vars`` at runtime.
|
||||
|
||||
Running Ansible adhoc Commands with Execution Environments
|
||||
----------------------------------------------------------
|
||||
|
||||
An example invocation using the ``ping`` module and ``localhost`` as target::
|
||||
|
||||
$ ansible-runner adhoc localhost -m ping
|
||||
|
||||
Something to note here is that implicit ``localhost`` in this context is a containerized instantiation of an Ansible Execution Environment and as such you will not get Ansible Facts about your system if using the ``setup`` module.
|
||||
|
||||
For more information, see :ref:`execution_environments`
|
||||
|
||||
Running Ansible ansible-playbook Commands with Execution Environments
|
||||
---------------------------------------------------------------------
|
||||
|
||||
An example invocation using the ``demo.yml`` playbook and ``inventory.ini`` inventory file::
|
||||
|
||||
$ ansible-runner playbook demo.yml -i inventory.ini
|
||||
|
||||
Something to note here is that implicit ``localhost`` in this context is a containerized instantiation of an Ansible Execution Environment and as such you will not get Ansible Facts about your system if using ``gather_facts: true`` and targeting ``localhost`` in your playbook without explicit host definition in your inventory.
|
||||
|
||||
For more information, see :ref:`execution_environments`
|
||||
|
||||
.. _outputjson:
|
||||
|
||||
Running with Process Isolation
|
||||
------------------------------
|
||||
|
||||
**Runner** supports process isolation. Process isolation creates a new mount namespace where the root is on a tmpfs that is invisible from the host
|
||||
and is automatically cleaned up when the last process exits. You can enable process isolation by providing the ``--process-isolation`` argument on
|
||||
the command line. **Runner** as of version 2.0 defaults to using ``podman`` as the process isolation executable, but supports
|
||||
using any executable that is compatible with the ``bubblewrap`` CLI arguments by passing in the ``--process-isolation-executable`` argument::
|
||||
|
||||
$ ansible-runner --process-isolation ...
|
||||
|
||||
**Runner** supports various process isolation arguments that allow you to provide configuration details to the process isolation executable. To view the complete
|
||||
list of arguments accepted by ``ansible-runner``::
|
||||
|
||||
$ ansible-runner --help
|
||||
|
||||
Running with Directory Isolation
|
||||
--------------------------------
|
||||
|
||||
If you need to be able to execute multiple tasks in parallel that might conflict with each other or if you want to make sure a single invocation of
|
||||
Ansible/Runner doesn't pollute or overwrite the playbook content you can give a base path::
|
||||
|
||||
$ ansible-runner --directory-isolation-base-path /tmp/runner
|
||||
|
||||
**Runner** will copy the project directory to a temporary directory created under that path, set it as the working directory, and execute from that location.
|
||||
After running that temp directory will be cleaned up and removed.
|
||||
|
||||
Outputting json (raw event data) to the console instead of normal output
|
||||
------------------------------------------------------------------------
|
||||
|
||||
**Runner** supports outputting json event data structure directly to the console (and stdout file) instead of the standard **Ansible** output, thus
|
||||
mimicing the behavior of the ``json`` output plugin. This is in addition to the event data that's already present in the artifact directory. All that is needed
|
||||
is to supply the ``-j`` argument on the command line::
|
||||
|
||||
$ ansible-runner ... -j ...
|
||||
|
||||
Cleaning up artifact directories
|
||||
--------------------------------
|
||||
|
||||
Using the command line argument ``--rotate-artifacts`` allows you to control the number of artifact directories that are present. Given a number as the parameter
|
||||
for this argument will cause **Runner** to clean up old artifact directories. The default value of ``0`` disables artifact directory cleanup.
|
||||
Reference in New Issue
Block a user