Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
build_error
glibcpy 3.10–3.910 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AntaInventory
✓ from anta.inventory import AntaInventory
AntaTest
✓ from anta.models import AntaTest
✗ from anta.anta_models import AntaTest
The core models were moved from `anta_models` to `models` in ANTA v1.0.0.
ResultManager
✓ from anta.result_manager import ResultManager
VerifyReachability
✓ from anta.tests.connectivity import VerifyReachability
Requires the `anta-lib-tests` package to be installed alongside `anta`.
main (CLI runner)
✓ from anta.runner import main
✗ import anta.runner
The `main` function from `anta.runner` is designed for CLI execution and parsing `argparse` arguments. Direct programmatic execution usually involves calling test methods manually on device objects.
This quickstart demonstrates how to programmatically define an ANTA inventory, specify tests, execute them against a device (mocked or real), and process the results. It assumes you have `anta` and `anta-lib-tests` installed. Credentials are loaded from environment variables `ANTA_USERNAME` and `ANTA_PASSWORD`, defaulting to 'admin' and 'arista' respectively. Replace '127.0.0.1' and test host IPs with your actual environment details.
import os
from anta.inventory import AntaInventory
from anta.models import AntaTest
from anta.tests.connectivity import VerifyReachability # Requires anta-lib-tests
from anta.result_manager import ResultManager
# 1. Define your inventory programmatically or load from a file
# This example uses a simple in-memory inventory for a single device.
# Replace '127.0.0.1' with your actual device's IP/hostname.
inventory_data = {
"lab": {
"hosts": {
"veos-01": {
"host": "127.0.0.1",
"port": 8443,
"username": os.environ.get('ANTA_USERNAME', 'admin'),
"password": os.environ.get('ANTA_PASSWORD', 'arista'),
"protocol": "https_vfy"
}
}
}
}
inventory = AntaInventory(inventory_data=inventory_data)
# 2. Define your tests using AntaTest objects
# This uses a built-in test from anta-lib-tests. Adjust 'hosts' for your network.
# Note: '1.1.1.1' and '2.2.2.2' are example unreachable hosts for a quick fail result.
# If you have real devices, replace with actual reachable/unreachable IPs.
tests_to_run = [
AntaTest(test=VerifyReachability, args={"hosts": ["1.1.1.1", "2.2.2.2"]})
]
# 3. Instantiate a ResultManager to collect test outcomes
result_manager = ResultManager()
# 4. Iterate over inventory devices and execute tests
print("--- Starting ANTA tests ---")
for device_name, device in inventory.get_devices().items():
print(f"\nRunning tests on device: {device_name} ({device.host})")
try:
device.connect() # Establish connection to the device
for anta_test in tests_to_run:
# Execute each test and record its result
print(f" Executing test: {anta_test.test.__name__}...")
anta_test.test(device=device, result_manager=result_manager) # Pass device and result_manager
device.close() # Close connection after tests
except Exception as e:
# Handle connection errors or general exceptions during test execution
print(f" ERROR during tests on {device_name}: {e}")
# Add a skipped/failed result for the first test if connection failed
if tests_to_run:
result_manager.add_failure(device=device, test=tests_to_run[0].test, result="SKIPPED", messages=[f"Could not connect or run tests: {e}"])
else:
print(f" No tests defined for {device_name}, but connection failed: {e}")
# 5. Print the aggregated test results
print("\n--- ANTA Test Results Summary ---")
for result in result_manager.get_results():
print(f"Device: {result.name}, Test: {result.test}, Result: {result.result}")
if result.messages:
for message in result.messages:
print(f" - {message}")
anta --version
Upgrade
Version history
1.8.0latest on PyPI · released Mar 11, 2026
Audit
Dependencies
anta-lib-testsrequiredProvides the official suite of built-in ANTA tests. Many quickstart examples and common use-cases rely on these tests.