{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/19085","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/19085/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/19085/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/19085/events","html_url":"https://github.com/ansible/ansible/issues/19085","id":194653202,"number":19085,"title":"include_role: inside a block: does not work with when: (even for non-string condition)","user":{"login":"joaocc","id":2837860,"avatar_url":"https://avatars.githubusercontent.com/u/2837860?v=3","gravatar_id":"","url":"https://api.github.com/users/joaocc","html_url":"https://github.com/joaocc","followers_url":"https://api.github.com/users/joaocc/followers","following_url":"https://api.github.com/users/joaocc/following{/other_user}","gists_url":"https://api.github.com/users/joaocc/gists{/gist_id}","starred_url":"https://api.github.com/users/joaocc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaocc/subscriptions","organizations_url":"https://api.github.com/users/joaocc/orgs","repos_url":"https://api.github.com/users/joaocc/repos","events_url":"https://api.github.com/users/joaocc/events{/privacy}","received_events_url":"https://api.github.com/users/joaocc/received_events","type":"User","site_admin":false},"labels":[{"id":437720699,"url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.2","name":"affects_2.2","color":"5319e7","default":false},{"id":48276055,"url":"https://api.github.com/repos/ansible/ansible/labels/bug_report","name":"bug_report","color":"fbca04","default":false},{"id":496359346,"url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":88746767,"url":"https://api.github.com/repos/ansible/ansible/labels/plugin","name":"plugin","color":"bfe5bf","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-09T17:32:46Z","updated_at":"2016-12-14T22:23:02Z","closed_at":"2016-12-14T22:21:32Z","body":"##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\ninclude_role:\r\n\r\n##### ANSIBLE VERSION\r\n```\r\nansible 2.2.0.0\r\n  config file =\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\n\r\n##### OS / ENVIRONMENT\r\nN/A\r\n\r\n##### SUMMARY\r\ninclude_role: inside a block: does not work with when: crashes when starting to execute the included role.\r\nIf I remove the external when: clause, everything works fine.\r\n\r\n##### STEPS TO REPRODUCE\r\n\r\ncalling script:\r\n```\r\n- block:\r\n    - include_role:\r\n          name: \"ansible-lib--infra/v1/ez123--moodle-moosh\"\r\n          static:  yes\r\n          private: yes\r\n      when:\r\n        \"{{ (zzz_moodle__skip__moosh is not defined) or (not (zzz_moodle__skip__moosh |bool)) }}\"\r\n```\r\non the included role, under tasks/main.yml\r\n```\r\n- name: \"check if moosh is already installed (1)\"\r\n  command: \"./moosh --help\"\r\n  args:\r\n    chdir: \"{{ ez123_moosh__bin_dir }}\"\r\n  register: _X_moosh_ver_0\r\n  changed_when: false\r\n  failed_when: false\r\n```\r\n##### EXPECTED RESULTS\r\nThere should be no error/crash.\r\n\r\n##### ACTUAL RESULTS\r\n```\r\nTASK [ansible-lib--infra/v1/ez123--moodle-moosh : check if moosh is already installed (1)] ***\r\ntask path: /etc/ansible/roles.glx/ansible-lib--infra/v1/ez123--moodle-moosh/tasks/main.yml:4\r\nfatal: [host000000]: FAILED! => {\r\n    \"failed\": true,\r\n    \"msg\": \"The conditional check '{' failed. The error was: template error while templating string: unexpected '%'. String: {% if { %} True {% else %} False {% endif %}\\n\\nThe error appears to have been in '/opt/src/ansible/dom/roles/dom-roles/func/tasks/main.yml': line 4, column 7, but may\\nbe elsewhere in the file depending on the exact syntax problem.\\n\\nThe offending line appears to be:\\n\\n- block:\\n    - include_role:\\n      ^ here\\n\"\r\n}```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/267175862","html_url":"https://github.com/ansible/ansible/issues/19085#issuecomment-267175862","issue_url":"https://api.github.com/repos/ansible/ansible/issues/19085","id":267175862,"user":{"login":"bcoca","id":836171,"avatar_url":"https://avatars.githubusercontent.com/u/836171?v=3","gravatar_id":"","url":"https://api.github.com/users/bcoca","html_url":"https://github.com/bcoca","followers_url":"https://api.github.com/users/bcoca/followers","following_url":"https://api.github.com/users/bcoca/following{/other_user}","gists_url":"https://api.github.com/users/bcoca/gists{/gist_id}","starred_url":"https://api.github.com/users/bcoca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcoca/subscriptions","organizations_url":"https://api.github.com/users/bcoca/orgs","repos_url":"https://api.github.com/users/bcoca/repos","events_url":"https://api.github.com/users/bcoca/events{/privacy}","received_events_url":"https://api.github.com/users/bcoca/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T22:23:02Z","updated_at":"2016-12-14T22:23:02Z","body":"also, don't use {{ }} in when, it is already interpolated"}}
{"actor":{"display_login":"bcoca"}}