Ansible Runner Python Example

Posted on  by 

Software Testing (LIVE Course). Example 2: Create a directory with the mode as 775 and owner/group as Ansible. Mar 23, 2017 What follows is an Ansible guide that will take you from installing Ansible to automatically deploying a long-running Python to a remote machine and running it in a Conda environment using supervisord. It presumes your development machine is on OS X and the remote machine is Debian-like; however, it shouldn't require too many changes to run it.

Note

This API is intended for internal Ansible use. Ansible may make changes to this API at any time that could break backward compatibility with older versions of the API. Because of this, external use is not supported by Ansible. If you want to use Python API only for executing playbooks or modules, consider ansible-runner first.

There are several ways to use Ansible from an API perspective. You can usethe Ansible Python API to control nodes, you can extend Ansible to respond to various Python events, you canwrite plugins, and you can plug in inventory data from external data sources. This documentgives a basic overview and examples of the Ansible execution and playbook API.

If you would like to use Ansible programmatically from a language other than Python, trigger events asynchronously,or have access control and logging demands, please see the AWX project.

Runner

Note

Because Ansible relies on forking processes, this API is not thread safe.

This example is a simple demonstration that shows how to minimally run a couple of tasks:

Note

Ansible emits warnings and errors via the display object, which prints directly to stdout, stderr and the Ansible log.

The source code for the ansiblecommand line tools (lib/ansible/cli/) is available on GitHub.

See also

Python Tutorial

Developing dynamic inventory

Developing dynamic inventory integrations

Developing Ansible modules
Ansible Runner Python Example

Getting started on developing a module

Developing plugins

Ansible Runner Python Example

How to develop plugins

Development Mailing List

Mailing list for development topics

irc.libera.chat

Ansible Python Api Example

#ansible IRC chat channel

Coments are closed