{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/10187","labels_url":"https://api.github.com/repos/ansible/ansible/issues/10187/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/10187/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/10187/events","html_url":"https://github.com/ansible/ansible/issues/10187","id":57016547,"number":10187,"title":"Jinja2 template is failing to render CONTINUE statement","user":{"login":"htgoebel","id":784161,"avatar_url":"https://avatars.githubusercontent.com/u/784161?v=3","gravatar_id":"","url":"https://api.github.com/users/htgoebel","html_url":"https://github.com/htgoebel","followers_url":"https://api.github.com/users/htgoebel/followers","following_url":"https://api.github.com/users/htgoebel/following{/other_user}","gists_url":"https://api.github.com/users/htgoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/htgoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htgoebel/subscriptions","organizations_url":"https://api.github.com/users/htgoebel/orgs","repos_url":"https://api.github.com/users/htgoebel/repos","events_url":"https://api.github.com/users/htgoebel/events{/privacy}","received_events_url":"https://api.github.com/users/htgoebel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-09T11:05:08Z","updated_at":"2015-02-09T11:05:08Z","closed_at":null,"body":"##### Issue Type:\r\nBug Report\r\n\r\n##### Ansible Version:\r\nansible 1.8.1\r\n\r\n##### Environment:\r\nN/A\r\n\r\n##### Summary:\r\njinja2 templates in ansible do not support ``continue`` in loops.\r\n\r\n##### Steps To Reproduce:\r\nSave this template as template-with-continue.j2\r\n```\r\n{%- for elem in my_items %}\r\n-- {{elem}} --\r\n{% continue %}\r\nshould not come here\r\n{% endfor %}\r\n```\r\nThen run this playbook:\r\n```\r\n---\r\n- hosts: all\r\n  gather_facts: False\r\n  vars:\r\n    my_items: [ 'item 1', 'item 2', 'item 3' ]\r\n  tasks:\r\n  - template:\r\n      src: template-with-continue.j2\r\n      dest: /tmp/template-with-continue.txt\r\n```\r\n\r\n##### Expected Results:\r\nI would expect the playbook to run without errors.\r\n\r\n##### Actual Results:\r\nAnsible errors out with (relevant part high-lighted):\r\n  fatal: [test] => {'msg': \"AnsibleError: file: template-with-continue.j2, line number: 3, error: **Encountered unknown tag 'continue'.** Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.\", 'failed': True}\r\n\r\n##### Possible solution\r\nAccording to http://stackoverflow.com/questions/16599338/jinja2-template-from-flask-is-failing-to-render-continue-statement you need to add the loop controls extension for Jinja 2 to your app:\r\n`app.jinja_env.add_extension('jinja2.ext.loopcontrols')`\r\n\r\n"}}