Escape Go template syntax in shell commands to prevent Ansible from
interpreting them as Jinja2 templates.
Errors fixed:
template error while templating string: unexpected '.'
String: docker version --format '{{.Server.Version}}'
String: docker images --format "{{.Repository}}:{{.Tag}}"
String: podman version --format '{{.Version}}'
Changes:
- Docker version check: Escape {{.Server.Version}}
- Docker images list: Escape {{.Repository}} and {{.Tag}}
- Podman version check: Escape {{.Version}}
Solution:
Convert {{ to {{ "{{" }} and }} to {{ "}}" }}
This tells Ansible to output literal {{ }} in the shell command
The Docker/Podman CLI then interprets the Go templates correctly
Example:
Before: '{{.Server.Version}}'
After: '{{ "{{" }}.Server.Version{{ "}}" }}'
Result: Shell receives '{{.Server.Version}}' as intended
Testing: Playbook now completes successfully without template errors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>