spark icon indicating copy to clipboard operation
spark copied to clipboard

[mirrorllist] template error when mirrorlist.country is absent

Open petRUShka opened this issue 1 year ago • 2 comments

There is a template error if mirrorlist.country is absent:

AnsibleError: template error while templating string: unexpected '}'. 

String: #!/bin/bash\n# {{ ansible_managed}\n#\n/usr/bin/reflector --latest 20 \\\n                   {% if mirrorlist.country %}--country {{ mirrorlist.country }} \\\n                   {% endif %}\n                   --sort rate \\\n                   --protocol https \\\n                   --save /etc/pacman.d/mirrorlist\n                   \nif [[ -f /etc/pacman.d/mirrorlist.pacnew ]]; then\n    rm /etc/pacman.d/mirrorlist.pacnew\nfi\n. unexpected '}'"

I believe that the solution is something like this:

{% if mirrorlist.country is defined and mirrorlist.country %}--country {{ mirrorlist.country }} \
{% endif %} 

petRUShka avatar Oct 19 '24 19:10 petRUShka

It seems that actual problem is missed closed } in # {{ ansible_managed}

petRUShka avatar Oct 19 '24 19:10 petRUShka

@petRUShka : that was my mistake, thanks for catching it. Pull request sent.

brett avatar Oct 19 '24 21:10 brett