This is my Ansible playbook to update /etc/hosts file:
- name: Update /etc/hosts file hosts: \"{{ target_hosts }}\" remote_user: awx become: yes bec
Is the syntax wrong?
Yes. Don't nest Jinja2 expressions. In your case {{ inside of {%.
{{
{%
Correct syntax:
{% for item in groups[target_hosts] %}