Because Ansible and Spira (SpiraTest, SpiraTeam, or SpiraPlan) both speak the "language" of JUnit XML, you can bridge them using the Spira xUnit Reporter (specifically the Python or NodeJS version of the spira-xunit-reader).
This creates a powerful "Infrastructure-as-Code" reporting loop: Ansible tests the server, generates a file, and the Spira reporter pushes those results into your Spira test management dashboard.
The 3-Step Workflow
1. Generate the JUnit XML (Ansible)
First, ensure Ansible is creating the report. As discussed, use the junit callback.
# Set environment variables so Ansible knows where to put the report
export ANSIBLE_CALLBACKS_ENABLED=ansible.builtin.junit
export JUNIT_OUTPUT_DIR=./test-results
# Run your playbook
ansible-playbook -i inventory.ini check_compliance.yml
This will create an XML file (e.g., localhost.xml) inside the ./test-results folder.
2. Configure the Spira Connection (spira.cfg)
The Spira xUnit reporter needs to know where to send the data. Create a file named spira.cfg in your project root:
[credentials]
url = https://your-instance.spiraservice.net
username = your_username
token = {Your-RSS-Token}
project_id = 1
release_id = 5 # Optional: Links results to a specific release
[test_cases]
# Map Ansible Task names to Spira Test Case IDs
# Format: host_name.task_name = Spira_TC_ID
webserver01.Verify_Apache_is_running = 105
webserver01.Check_SSL_Certificate = 106
3. Push to Spira (The Reporter)
Now, use the spira-xunit-reader to upload the results. You can install it via pip:
pip install spira-addons-xunit
Then, run the command to sync the results:
python -m spira_xunit_reader ./test-results/localhost.xml spira.cfg
Why this is useful for Rapise users
If you already use Rapise, you likely have your functional UI tests reporting into Spira. By adding this Ansible flow:
Rapise reports on: "Is the Login Page working?"
Ansible reports on: "Is the Web Server configured securely?"
Spira gives you a Single Pane of Glass showing that both the code (Rapise) and the environment (Ansible) are healthy.
Key Logic Mapping
| Ansible Component | JUnit Element | Spira Component |
|---|
| Playbook Run | <testsuite> | Test Run |
| Individual Task | <testcase> | Test Step / Case |
| Task Failure | <failure> | Failed Test Run |
| Task Output | <system-out> | Execution Log |
Export to Sheets
Pro-Tip: CI/CD Automation
In a tool like Jenkins or GitLab, your script block would look like this:
ansible-playbook ... (Run infrastructure tests)
python -m spira_xunit_reader ... (Upload to Spira)
This ensures that every time you deploy a server, Spira is updated automatically with the "Health Check" results.