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:

  1. Verify that the collection is installed:
    ansible-galaxy collection list | grep storage_protect
  2. 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:

  1. Verify that the environment variables are set:
    echo $STORAGE_PROTECT_SERVERNAME
    echo $STORAGE_PROTECT_USERNAME
  2. Test the credentials manually:
    dsmadmc -id=$STORAGE_PROTECT_USERNAME -password=$STORAGE_PROTECT_PASSWORD \
      -servername=$STORAGE_PROTECT_SERVERNAME "query status"
  3. 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:

  1. To update to the latest version, issue the following command:
    ansible-galaxy collection install ibm.storage_protect --force
  2. 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:

  1. Generate the baseline first:
    ansible-playbook -i inventory.ini \
      ibm.storage_protect.sp_server_facts_playbook.yml \
      -e @vars.yml
  2. Verify that the baseline was created:
    ls -lh reports/baseline_*.json
  3. 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:

Ensure that snapshots follow the required schema:
{
  "data": {
    "ansible_module_results": {
      "q_status": {},
      "q_db": {}
    }
  }
}
Verify the snapshot structure:
jq '.data.ansible_module_results | keys' reports/current_host.json

Problem: Permission denied on reports directory

Symptom: Cannot write to reports directory

Solution:

  1. Create the directory with proper permissions:
    mkdir -p reports
    chmod 750 reports
    chown $USER:$USER reports
  2. Verify the permissions:
    ls -ld reports

Problem: Drift report shows unexpected changes

Symptom: Drift report includes volatile fields like timestamps

Solution:

Add volatile fields to the ignore list:
python3 scripts/sp_config_diff.py baseline.json current.json \
  --out diff_report.json \
  --ignore-keys timestamp,last_checked,scan_id,collected_at,next_run

Problem: Multi-host baseline acceptance issues

Symptom: Cannot accept drift for specific hosts

Solution:

  1. Ensure that the hostnames match the inventory:
    ansible-inventory -i inventory.ini --list | jq '.all.hosts'
  2. 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:

Ensure that all query flags are properly configured:
sp_server_facts_flags:
  q_status: true
  q_db: true
  # ... enable other queries
Verify the coverage in the snapshot:
jq '.enabled_queries, .total_queries, .query_coverage_pct' reports/current_host.json

Problem: Large snapshot files

Symptom: Snapshot files are too large, causing performance issues

Solution:

  1. Disable unnecessary queries by editing the vars.yml file and setting unused queries to false.

  2. Compress old snapshots:
    gzip reports/SpServerResponseMapper.*.json
  3. Implement a retention policy:
    find reports/ -name "SpServerResponseMapper.*.json" -mtime +30 -delete

Debug mode

Enable verbose output for troubleshooting:

  1. Run the playbook with the verbose flag:
    ansible-playbook -i inventory.ini \
      ibm.storage_protect.sp_server_facts_playbook.yml \
      -e @vars.yml -vvv
  2. 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