Resolving configuration drift detection problems
Quick reference for resolving common drift detection problems.
Overview
Use this reference to resolve common drift detection issues. For an overview of drift detection, see Configuration drift detection overview.
Problem: Module not found error
Symptom: ERROR! couldn't resolve module/action 'ibm.storage_protect.sp_server_facts'
Solution:
-
Verify that the collection is installed:
ansible-galaxy collection list | grep storage_protect -
Reinstall the collection if needed:
ansible-galaxy collection install ibm.storage_protect --force
Problem: Authentication failures
Symptom: Connection or authentication errors when you query the server
Solution:
-
Verify that the environment variables are set:
echo $STORAGE_PROTECT_SERVERNAME echo $STORAGE_PROTECT_USERNAME -
Test the credentials manually:
dsmadmc -id=$STORAGE_PROTECT_USERNAME -password=$STORAGE_PROTECT_PASSWORD \ -servername=$STORAGE_PROTECT_SERVERNAME "query status" -
Check SSH connectivity:
ansible -i inventory.ini all -m ping
Problem: AttributeError in drift detection
Symptom: AttributeError when you compare list values in changed dictionaries
Solution:
This issue was fixed in version 1.1.0 with enhanced type handling. Ensure that you use the latest version:
-
To update to the latest version, issue the following command:
ansible-galaxy collection install ibm.storage_protect --force -
Verify the version:
ansible-galaxy collection list ibm.storage_protect
Problem: Empty or missing baseline
Symptom: Drift report shows all changes as "added" or baseline file not found
Solution:
-
Generate the baseline first:
ansible-playbook -i inventory.ini \ ibm.storage_protect.sp_server_facts_playbook.yml \ -e @vars.yml -
Verify that the baseline was created:
ls -lh reports/baseline_*.json -
If the baseline exists but is empty, check the query flags:
cat vars.yml | grep -A 15 sp_server_facts_flags
Problem: Snapshot schema mismatch
Symptom: Drift comparison fails due to unexpected JSON structure
Solution:
{
"data": {
"ansible_module_results": {
"q_status": {},
"q_db": {}
}
}
}jq '.data.ansible_module_results | keys' reports/current_host.jsonProblem: Permission denied on reports directory
Symptom: Cannot write to reports directory
Solution:
-
Create the directory with proper permissions:
mkdir -p reports chmod 750 reports chown $USER:$USER reports -
Verify the permissions:
ls -ld reports
Problem: Drift report shows unexpected changes
Symptom: Drift report includes volatile fields like timestamps
Solution:
python3 scripts/sp_config_diff.py baseline.json current.json \
--out diff_report.json \
--ignore-keys timestamp,last_checked,scan_id,collected_at,next_runProblem: Multi-host baseline acceptance issues
Symptom: Cannot accept drift for specific hosts
Solution:
-
Ensure that the hostnames match the inventory:
ansible-inventory -i inventory.ini --list | jq '.all.hosts' -
Use exact hostnames when you select hosts. For example, use v1,v2 (not v1, v2 with spaces).
Problem: Coverage metrics not showing
Symptom: Coverage metrics missing from drift report
Solution:
sp_server_facts_flags:
q_status: true
q_db: true
# ... enable other queriesjq '.enabled_queries, .total_queries, .query_coverage_pct' reports/current_host.jsonProblem: Large snapshot files
Symptom: Snapshot files are too large, causing performance issues
Solution:
-
Disable unnecessary queries by editing the vars.yml file and setting unused queries to
false. -
Compress old snapshots:
gzip reports/SpServerResponseMapper.*.json -
Implement a retention policy:
find reports/ -name "SpServerResponseMapper.*.json" -mtime +30 -delete
Debug mode
Enable verbose output for troubleshooting:
-
Run the playbook with the verbose flag:
ansible-playbook -i inventory.ini \ ibm.storage_protect.sp_server_facts_playbook.yml \ -e @vars.yml -vvv -
Check the Ansible logs:
export ANSIBLE_LOG_PATH=./ansible.log ansible-playbook -i inventory.ini \ ibm.storage_protect.sp_server_facts_playbook.yml \ -e @vars.yml
Getting help
- Review module documentation: ansible-doc ibm.storage_protect.sp_server_facts
- Check GitHub issues: https://github.com/IBM/ansible-storage-protect/issues
- Review example playbooks: https://github.com/IBM/ansible-storage-protect/tree/main/playbooks/