This guide will walk you through the installation and setup of the Ansible Scenario Testing Framework.
- Python 3.10 or higher
- pip package manager
- Ansible 2.9 or higher
To install the library in development mode, which allows you to make changes to the code:
cd /home/viewnext/src/ANSIBLE_TOOLS/ansible-scenario-testing
pip install -e .This will install the package in "editable" mode, meaning changes to the source code will be immediately available.
To build a distribution package that can be installed elsewhere:
cd /home/viewnext/src/ANSIBLE_TOOLS/ansible-scenario-testing
python setup.py sdist bdist_wheelThis will create distribution files in the dist/ directory.
To verify that the installation was successful, run the following Python code:
from ansible_playtest.core.scenario import Scenario
from ansible_playtest.core.test_runner import AnsiblePlaybookTestRunner
print("Installation successful!")An example test script and scenario are included in the examples/ directory:
cd ansible-scenario-testing
python examples/run_test.py path/to/your/playbook.yml --scenario examples/scenarios/example_scenario.yamlTo integrate the framework with your existing project:
- Import the necessary components:
from ansible_playtest.core.runner import run_playbook_test-
Create scenario files in your project's test directory
-
Run your tests:
results = run_playbook_test(
playbook_path='your_playbook.yml',
scenario_path='your_scenario.yaml'
)- Review the documentation in the
docs/directory - Explore the example scenario in
examples/scenarios/ - Create your own test scenarios
If you encounter issues with the installation or usage:
- Ensure you have the required Python version:
python --version - Check that Ansible is installed:
ansible --version - Verify that aiosmtpd and other dependencies are installed:
pip list | grep aiosmtpd