From 8df343182f664a9844a3a1b2ef85a5649dbba12b Mon Sep 17 00:00:00 2001 From: ansible Date: Tue, 11 Nov 2025 01:52:22 +0100 Subject: [PATCH] Fix Jinja2 template conflicts in Docker and Podman detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- roles/system_info/tasks/detect_hypervisor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/system_info/tasks/detect_hypervisor.yml b/roles/system_info/tasks/detect_hypervisor.yml index e4f51be..9a6d612 100644 --- a/roles/system_info/tasks/detect_hypervisor.yml +++ b/roles/system_info/tasks/detect_hypervisor.yml @@ -164,7 +164,7 @@ - name: Check for Docker shell: | if command -v docker &> /dev/null; then - docker version --format '{{.Server.Version}}' 2>/dev/null || echo "Docker installed but not running" + docker version --format '{{ "{{" }}.Server.Version{{ "}}" }}' 2>/dev/null || echo "Docker installed but not running" else echo "Docker not installed" fi @@ -188,7 +188,7 @@ failed_when: false - name: List Docker images - shell: docker images --format "{{.Repository}}:{{.Tag}}" | wc -l + shell: docker images --format "{{ "{{" }}.Repository{{ "}}" }}:{{ "{{" }}.Tag{{ "}}" }}" | wc -l register: system_info_docker_images_raw changed_when: false failed_when: false @@ -201,7 +201,7 @@ - name: Check for Podman shell: | if command -v podman &> /dev/null; then - podman version --format '{{.Version}}' + podman version --format '{{ "{{" }}.Version{{ "}}" }}' else echo "Podman not installed" fi