{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/16366","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/16366/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/16366/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/16366/events","html_url":"https://github.com/ansible/ansible/issues/16366","id":161151869,"number":16366,"title":"Missing a with_items/when combination","user":{"login":"ejournet","id":12510792,"avatar_url":"https://avatars.githubusercontent.com/u/12510792?v=3","gravatar_id":"","url":"https://api.github.com/users/ejournet","html_url":"https://github.com/ejournet","followers_url":"https://api.github.com/users/ejournet/followers","following_url":"https://api.github.com/users/ejournet/following{/other_user}","gists_url":"https://api.github.com/users/ejournet/gists{/gist_id}","starred_url":"https://api.github.com/users/ejournet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejournet/subscriptions","organizations_url":"https://api.github.com/users/ejournet/orgs","repos_url":"https://api.github.com/users/ejournet/repos","events_url":"https://api.github.com/users/ejournet/events{/privacy}","received_events_url":"https://api.github.com/users/ejournet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-20T09:21:58Z","updated_at":"2016-06-20T11:12:28Z","closed_at":null,"body":"##### ISSUE TYPE\r\n - Feature Idea\r\n\r\n##### ANSIBLE VERSION\r\nansible 2.1.0.0\r\n\r\n##### CONFIGURATION\r\nconfigured module search path = Default w/o overrides\r\n\r\n##### OS / ENVIRONMENT\r\nCentOS 6\r\n\r\n##### SUMMARY\r\nI'm looking for a mean to combine conditions (with when) and list (with with_items). \r\nExample : I need to copy several files, I'll use the with_items tool. But if now I want to copy one of these files under a condition, I'll have to create a new step. \r\n\r\n##### STEPS TO REPRODUCE\r\nIf I want ton copy \"example2\" file on \"condition\" : \r\n'with_items:'\r\n'  - example1'\r\n'  - example2'\r\n'    when : condition'\r\n'  - example3'\r\n\r\nIf I want to copy \"example1\" on \"condition1\" and \"example2\" on \"condition2\" : \r\n'with_items:\r\n' - example1'\r\n'   when : condition1'\r\n' - example2'\r\n'   when : condition2'\r\n \r\n(sorry for formatting, didnt quite get how to do it)\r\n##### EXPECTED RESULTS\r\nFirst example : example1 and example3 are normally copied but example2 is only copied when condition is fulfilled.\r\nSecond example : example1 is copied when condition1 fulfilled and example2 is copied when condition2 fulfilled\r\n\r\n##### ACTUAL RESULTS\r\nSyntax Error\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/227114493","html_url":"https://github.com/ansible/ansible/issues/16366#issuecomment-227114493","issue_url":"https://api.github.com/repos/ansible/ansible/issues/16366","id":227114493,"user":{"login":"kustodian","id":1949229,"avatar_url":"https://avatars.githubusercontent.com/u/1949229?v=3","gravatar_id":"","url":"https://api.github.com/users/kustodian","html_url":"https://github.com/kustodian","followers_url":"https://api.github.com/users/kustodian/followers","following_url":"https://api.github.com/users/kustodian/following{/other_user}","gists_url":"https://api.github.com/users/kustodian/gists{/gist_id}","starred_url":"https://api.github.com/users/kustodian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kustodian/subscriptions","organizations_url":"https://api.github.com/users/kustodian/orgs","repos_url":"https://api.github.com/users/kustodian/repos","events_url":"https://api.github.com/users/kustodian/events{/privacy}","received_events_url":"https://api.github.com/users/kustodian/received_events","type":"User","site_admin":false},"created_at":"2016-06-20T11:12:27Z","updated_at":"2016-06-20T11:12:27Z","body":"Why not use something like this:\r\n```yml\r\n- copy: src={{ item }} dest=/some/dest\r\n  when: (item='example1' and condition1) or (item='example2' and condition2)\r\n  with_items:\r\n    - example1\r\n    - example2\r\n```\r\n\r\nYou better give a concrete example what you want to do, there is probably a way to do it already."}}
{"actor":{"display_login":"kustodian"}}