Troubleshooting Guide#
Common issues and solutions for Chef-to-Ansible migrations.
Table of Contents#
- Migration Failures
- Conversion Issues
- Validation Errors
- Deployment Problems
- Performance Issues
- Chef Server Connectivity
- Storage and State
Migration Failures#
Issue: Cookbook Not Found#
Symptoms:
Solutions:
-
Verify path is correct:
-
Check cookbook structure:
-
Use absolute paths:
Issue: Migration Hangs or Times Out#
Symptoms: - Migration process appears frozen - No output for extended period - Process eventually times out
Solutions:
-
Check for large files:
Large template files can slow parsing. Consider excluding or optimizing them. -
Increase timeout (if using MCP):
-
Enable debug logging:
-
Break into smaller chunks:
Issue: Partial Success with Warnings#
Symptoms:
Solutions:
-
Review specific warnings:
-
Identify problematic resources:
# Check metrics for manual review items print(f"Manual review needed: {result.metrics.resources_manual_review}") # Review generated playbooks for REVIEW markers import re for playbook_path in result.playbooks_generated: with open(playbook_path) as f: content = f.read() review_markers = re.findall(r"# REVIEW:.*", content) if review_markers: print(f"\n{playbook_path}:") for marker in review_markers: print(f" {marker}") -
Common manual review cases:
- Complex Ruby guards:
only_if { complex_ruby_expression } - Custom resource properties not directly mappable
- Nested attribute references
- Dynamic resource names
Conversion Issues#
Issue: Guards Not Converting Properly#
Symptoms:
# REVIEW: manual guard conversion needed: node['platform'] == 'ubuntu' && custom_method?
when: ansible_check_mode
Solutions:
- Simplify Chef guards:
Instead of:
Split into separate checks:
-
Use standard Chef idioms:
-
Post-process guards manually:
import yaml for playbook_path in result.playbooks_generated: with open(playbook_path) as f: playbook = yaml.safe_load(f) # Find and fix guard conditions for play in playbook: for task in play.get('tasks', []): if 'when' in task and 'REVIEW' in str(task['when']): # Manual fix logic print(f"Fix needed: {task['name']}")
Issue: Handlers Not Generated#
Symptoms:
- Chef notifies present but no Ansible handlers created
- Playbook runs but services don't restart
Solutions:
-
Check notification syntax:
-
Verify handler section:
-
Manual handler addition:
Issue: Template Conversion Fails#
Symptoms:
Solutions:
-
Validate ERB templates:
-
Fix common ERB issues:
-
Skip problematic templates:
# Copy as-is and mark for manual conversion import shutil from pathlib import Path templates_dir = Path(cookbook_path) / "templates" for template in templates_dir.rglob("*.erb"): try: # Attempt conversion convert_template_to_jinja2(str(template)) except Exception as e: print(f"Skipping {template.name}: {e}") # Copy for manual review shutil.copy(template, f"manual-review/{template.name}")
Validation Errors#
Issue: Playbook Fails ansible-lint#
Symptoms:
[701] Role info should contain platforms
[206] Variables should have spaces before and after: {{ var }}
Solutions:
-
Auto-fix with ansible-lint:
-
Common fixes:
Missing spaces in Jinja2:
Quote all Jinja2 expressions:
- Configure ansible-lint exceptions:
Issue: Syntax Errors in Generated Playbooks#
Symptoms:
Solutions:
-
Validate YAML:
-
Common YAML issues:
Incorrect indentation:
# Wrong
- name: Task
ansible.builtin.package:
name: nginx
# Correct
- name: Task
ansible.builtin.package:
name: nginx
Unquoted special characters:
- Use validation in code:
Deployment Problems#
Issue: Cannot Connect to Ansible Platform#
Symptoms:
Solutions:
-
Verify connectivity:
-
Check credentials:
from souschef.api_clients import AAPClient client = AAPClient( server_url="https://aap.example.com", username="admin", password="password", verify_ssl=False, # Only for testing! ) try: version = client.get_api_version() print(f"Connected! Version: {version}") except Exception as e: print(f"Connection failed: {e}") -
Update SSL certificates:
Issue: Inventory Creation Fails#
Symptoms:
Solutions:
-
Check inventory name:
-
Verify permissions:
-
Use organization parameter:
Issue: Job Template Creation Fails#
Symptoms:
Solutions:
-
Ensure dependencies exist:
# Create in order inv = client.create_inventory("my-inv") proj = client.create_project("my-project", scm_type="git", scm_url="https://github.com/org/repo") # Wait for project sync import time time.sleep(5) # Then create job template jt = client.create_job_template( name="my-job", inventory=inv['id'], project=proj['id'], playbook="site.yml", ) -
Check required fields:
Performance Issues#
Issue: Migration Takes Too Long#
Symptoms: - Large cookbooks (100+ recipes) take hours - System becomes unresponsive
Solutions:
-
Skip validation during migration:
-
Parallelize recipe processing:
from concurrent.futures import ThreadPoolExecutor from pathlib import Path recipes = list(Path(cookbook_path / "recipes").glob("*.rb")) def migrate_recipe(recipe_path): return generate_playbook_from_recipe(str(recipe_path)) with ThreadPoolExecutor(max_workers=4) as executor: playbooks = list(executor.map(migrate_recipe, recipes)) -
Use profiling:
Issue: High Memory Usage#
Symptoms: - Process uses >2GB RAM - System swapping/OOM errors
Solutions:
-
Process recipes individually:
-
Disable caching:
-
Limit concurrent operations:
Chef Server Connectivity#
Issue: Authentication Failed#
Symptoms:
Solutions:
-
Verify client key:
-
Check client name:
-
Test connection:
from souschef.core.chef_server import _validate_chef_server_connection success, message = _validate_chef_server_connection( server_url="https://chef.example.com", client_name="migration-client", organisation="default", client_key_path="/etc/chef/migration.pem", ) if not success: print(f"Connection failed: {message}")
Issue: Node Search Returns No Results#
Symptoms:
Solutions:
-
Verify search syntax:
-
Check organization:
-
Test with wildcard:
Storage and State#
Issue: Cannot Save Migration State#
Symptoms:
Solutions:
-
Check database connection:
-
Initialize database:
-
Check permissions:
Issue: Migration ID Not Found#
Symptoms:
Solutions:
-
List available migrations:
-
Verify migration was saved:
-
Check database file location:
Getting Help#
Enable Debug Logging#
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
)
# Now run migration
result = orchestrator.migrate_cookbook(cookbook_path)
Capture Detailed Error Information#
import traceback
try:
result = orchestrator.migrate_cookbook(cookbook_path)
except Exception as e:
print("="*60)
print("DETAILED ERROR INFORMATION")
print("="*60)
print(f"Exception type: {type(e).__name__}")
print(f"Exception message: {e}")
print("\nFull traceback:")
traceback.print_exc()
print("="*60)
Report Issues#
When reporting issues, include:
-
SousChef version:
-
Environment:
- OS and version
- Python version
- Chef version being migrated
-
Target Ansible platform and version
-
Minimal reproduction:
- Smallest cookbook that reproduces the issue
- Exact command or code that fails
-
Full error message and traceback
-
Migration result (if available):