Registry / devops / ansible

ansible

JSON →
library14.3.1pypypi✓ verified 25d ago

Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and other IT needs. The `ansible` PyPI package (currently v13.5.0) is a meta-package that bundles `ansible-core` (the engine) and various `ansible-collections` for modules and plugins. It follows a release cadence tied to the `ansible-core` and collection ecosystem, with major updates typically released quarterly.

pip install ansible
INSTALL
IMPORT
SIG · ANSIBLE
A
ansible
devopspythonv14.3.1
Install
9.8s avg
Import
Disk
289MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v10.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.915 runs
installs and imports cleanly · install 0.0s · import 0.000s · 71.5MB
glibc
py 3.103.915 runs
installs and imports cleanly · install 9.8s · import 0.000s · 458MB
289MB installed
● package 289MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

run
from ansible_collections import run
from ansible_collections import run

This quickstart demonstrates running a simple Ansible playbook programmatically using `ansible-runner`. It creates a temporary directory for Ansible to work in, defines a basic playbook, and executes it. Ensure `ansible-runner` is installed (`pip install ansible-runner`).

import os import shutil import ansible_runner # Define a simple playbook playbook_content = """ - name: Hello Ansible hosts: localhost gather_facts: no tasks: - name: Display message ansible.builtin.debug: msg: "Ansible is running from Python!" """ # Create a temporary directory for the run temp_dir = "./ansible_quickstart_temp" os.makedirs(temp_dir, exist_ok=True) # Write the playbook to a file in the temp directory playbook_path = os.path.join(temp_dir, "hello.yml") with open(playbook_path, "w") as f: f.write(playbook_content) try: # Run the playbook using ansible-runner # private_data_dir is essential for ansible-runner to function r = ansible_runner.run( private_data_dir=temp_dir, playbook="hello.yml", inventory={"localhost": {"hosts": ["localhost"]}}, # Minimal inventory quiet=True # Suppress some verbose output ) print(f"\nAnsible Runner Status: {r.status}") if r.rc == 0: print("Playbook executed successfully.") # Optionally, print captured stdout from events for event in r.events: if 'event' in event and event['event'] == 'runner_on_ok' and 'msg' in event['event_data']['res']: print(f" Task output: {event['event_data']['res']['msg']}") else: print(f"Playbook failed with return code: {r.rc}") print(f"Errors: {r.stderr}") # ansible-runner captures stderr except Exception as e: print(f"An error occurred: {e}") finally: # Clean up the temporary directory if os.path.exists(temp_dir): shutil.rmtree(temp_dir) print("Cleanup complete.")
ansible --version
Debug
Known issues
gotchaThe `ansible` PyPI package is a meta-package. It installs `ansible-core` and many `ansible-collections`. For minimal setups or specific programmatic tasks, `pip install ansible-core` or `pip install ansible-runner` might be sufficient and lead to a smaller installation footprint.
fix
Evaluate your specific needs. If you only need the core engine or programmatic execution via `ansible-runner`, install `ansible-core` or `ansible-runner` directly.
affects: All versions
breakingPython version compatibility changes frequently with `ansible-core` releases. Newer `ansible-core` versions drop support for older Python versions. The `ansible` meta-package version 13.5.0 requires Python >=3.12, reflecting its underlying `ansible-core` 2.16.x.
fix
Always check the `requires_python` metadata on PyPI for the specific `ansible` or `ansible-core` version you intend to use. Ensure your Python environment meets the requirements.
affects: All major `ansible-core` upgrades (e.g., 2.12, 2.15, 2.16 and beyond)
gotchaDirectly importing from `ansible.*` internal modules (e.g., `ansible.playbook`, `ansible.executor`) for programmatic interaction is generally discouraged. These are internal APIs and are subject to change without warning between versions, leading to unstable code.
fix
Use `ansible-runner` for stable and officially supported programmatic execution of Ansible playbooks and commands in Python. It provides a robust API that is less likely to break.
affects: All versions, especially across `ansible-core` major changes
breakingMajor version upgrades of `ansible-core` (e.g., 2.9 to 2.10, 2.11 to 2.12, etc.) frequently introduce breaking changes in module arguments, plugin interfaces, and internal data structures. This can affect custom modules, plugins, or scripts that directly interact with Ansible's internals.
fix
Refer to the `ansible-core` release notes (e.g., `https://docs.ansible.com/ansible/devel/dev_guide/developing_breaking_changes.html`) before upgrading. Thoroughly test custom code and playbooks with new versions.
affects: All major `ansible-core` upgrades
Upgrade
Version history
14.3.1latest on PyPI · released Aug 14, 2026
Audit
Dependencies
ansible-corerequiredThe underlying engine for Ansible operations, automatically installed by the `ansible` meta-package.
ansible-runneroptionalRecommended for stable programmatic execution of playbooks and ad-hoc commands in Python.
ansible-collections.*requiredVarious collections providing modules, plugins, etc., automatically installed by the `ansible` meta-package.
Agent activity
69 hits · last 30 days
node
60
OpenAI (training)
1
Resources
ansible — pip install ansible · libregistry