{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/14332","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/14332/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/14332/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/14332/events","html_url":"https://github.com/ansible/ansible/pull/14332","id":131654473,"number":14332,"title":"Introduce new 'filetree' lookup plugin","user":{"login":"dagwieers","id":388198,"avatar_url":"https://avatars.githubusercontent.com/u/388198?v=3","gravatar_id":"","url":"https://api.github.com/users/dagwieers","html_url":"https://github.com/dagwieers","followers_url":"https://api.github.com/users/dagwieers/followers","following_url":"https://api.github.com/users/dagwieers/following{/other_user}","gists_url":"https://api.github.com/users/dagwieers/gists{/gist_id}","starred_url":"https://api.github.com/users/dagwieers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dagwieers/subscriptions","organizations_url":"https://api.github.com/users/dagwieers/orgs","repos_url":"https://api.github.com/users/dagwieers/repos","events_url":"https://api.github.com/users/dagwieers/events{/privacy}","received_events_url":"https://api.github.com/users/dagwieers/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_pull_request","name":"feature_pull_request","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/ansible/ansible/milestones/8","html_url":"https://github.com/ansible/ansible/milestones/2.2.0","labels_url":"https://api.github.com/repos/ansible/ansible/milestones/8/labels","id":1702615,"number":8,"title":"2.2.0","description":"","creator":{"login":"sivel","id":39340,"avatar_url":"https://avatars.githubusercontent.com/u/39340?v=3","gravatar_id":"","url":"https://api.github.com/users/sivel","html_url":"https://github.com/sivel","followers_url":"https://api.github.com/users/sivel/followers","following_url":"https://api.github.com/users/sivel/following{/other_user}","gists_url":"https://api.github.com/users/sivel/gists{/gist_id}","starred_url":"https://api.github.com/users/sivel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sivel/subscriptions","organizations_url":"https://api.github.com/users/sivel/orgs","repos_url":"https://api.github.com/users/sivel/repos","events_url":"https://api.github.com/users/sivel/events{/privacy}","received_events_url":"https://api.github.com/users/sivel/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":1,"state":"open","created_at":"2016-04-12T23:10:49Z","updated_at":"2016-05-12T01:07:35Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2016-02-05T14:10:29Z","updated_at":"2016-05-12T01:07:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/14332","html_url":"https://github.com/ansible/ansible/pull/14332","diff_url":"https://github.com/ansible/ansible/pull/14332.diff","patch_url":"https://github.com/ansible/ansible/pull/14332.patch"},"body":"##### ISSUE TYPE\r\n - Feature Pull Request\r\n\r\n##### ANSIBLE VERSION\r\nv2.0\r\n\r\n##### SUMMARY\r\nThe new \"filetree\" lookup plugin makes it possible to recurse over a tree of files within the task loop. This makes it possible to e.g. template a complete tree of files to a target system with little effort while retaining permissions and ownership.\r\n\r\nThe module supports directories, files and symlinks. And also SELinux.\r\n\r\nIf you provide more than one path, it will implement a `with_first_found` logic, and will not process entries it already processed in previous paths. This enables the user to merge different trees in order of importance, or add e.g. role_vars specific paths to influence different instances of the same role.\r\n\r\nThe item dictionary consists of:\r\n - src\r\n - root\r\n - path\r\n - mode\r\n - state\r\n - owner\r\n - group\r\n - seuser\r\n - serole\r\n - setype\r\n - selevel\r\n - uid\r\n - gid\r\n - size\r\n - mtime\r\n - ctime\r\n\r\n##### EXAMPLES\r\nHere is an example of how we use with_filetree within a role.\r\nThe `web/` path is relative to either `roles/<role>/files/` or `files/`.\r\n\r\n```yaml\r\n - name: Create directories\r\n   file:\r\n     path: /web/{{ item.path }}\r\n     state: directory\r\n     mode: '{{ item.mode }}'\r\n   with_filetree: web/\r\n   when: item.state == 'directory'\r\n\r\n - name: Template files\r\n   template:\r\n     src: '{{ item.src }}'\r\n     dest: /web/{{ item.path }}\r\n     mode: '{{ item.mode }}'\r\n   with_filetree: web/\r\n   when: item.state == 'file'\r\n\r\n - name: Recreate symlinks\r\n   file:\r\n     src: '{{ item.src }}'\r\n     dest: /web/{{ item.path }}\r\n     state: link\r\n     force: yes\r\n     mode: '{{ item.mode }}'\r\n   with_filetree: web/\r\n   when: item.state == 'link'\r\n```\r\n\r\n##### SPECIAL USE\r\nThe following properties also have its special use:\r\n\r\n - root: Makes it possible to filter by original location\r\n - path: Is the relative path to root\r\n - uid, gid: Makes it possible to force-create by exact id, rather than by name\r\n - size, mtime, ctime: Makes it possible to filter out files by size, mtime or ctime"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/218633723","html_url":"https://github.com/ansible/ansible/pull/14332#issuecomment-218633723","issue_url":"https://api.github.com/repos/ansible/ansible/issues/14332","id":218633723,"user":{"login":"jimi-c","id":26403,"avatar_url":"https://avatars.githubusercontent.com/u/26403?v=3","gravatar_id":"","url":"https://api.github.com/users/jimi-c","html_url":"https://github.com/jimi-c","followers_url":"https://api.github.com/users/jimi-c/followers","following_url":"https://api.github.com/users/jimi-c/following{/other_user}","gists_url":"https://api.github.com/users/jimi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/jimi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimi-c/subscriptions","organizations_url":"https://api.github.com/users/jimi-c/orgs","repos_url":"https://api.github.com/users/jimi-c/repos","events_url":"https://api.github.com/users/jimi-c/events{/privacy}","received_events_url":"https://api.github.com/users/jimi-c/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T01:07:54Z","updated_at":"2016-05-12T01:07:54Z","body":"@dagwieers sorry this didn't make the cut, adjusted the milestone so we can grab it for 2.2."}}