{"action":"created","issue":{"url":"https://api.github.com/repos/roots/trellis/issues/242","labels_url":"https://api.github.com/repos/roots/trellis/issues/242/labels{/name}","comments_url":"https://api.github.com/repos/roots/trellis/issues/242/comments","events_url":"https://api.github.com/repos/roots/trellis/issues/242/events","html_url":"https://github.com/roots/trellis/pull/242","id":88325171,"number":242,"title":"Copy files/includes and populate templates/includes and add to includes.d.","user":{"login":"chriszarate","id":739304,"avatar_url":"https://avatars.githubusercontent.com/u/739304?v=3","gravatar_id":"","url":"https://api.github.com/users/chriszarate","html_url":"https://github.com/chriszarate","followers_url":"https://api.github.com/users/chriszarate/followers","following_url":"https://api.github.com/users/chriszarate/following{/other_user}","gists_url":"https://api.github.com/users/chriszarate/gists{/gist_id}","starred_url":"https://api.github.com/users/chriszarate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriszarate/subscriptions","organizations_url":"https://api.github.com/users/chriszarate/orgs","repos_url":"https://api.github.com/users/chriszarate/repos","events_url":"https://api.github.com/users/chriszarate/events{/privacy}","received_events_url":"https://api.github.com/users/chriszarate/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/roots/trellis/labels/under%20development","name":"under development","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-15T05:42:50Z","updated_at":"2015-07-10T03:08:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/roots/trellis/pulls/242","html_url":"https://github.com/roots/trellis/pull/242","diff_url":"https://github.com/roots/trellis/pull/242.diff","patch_url":"https://github.com/roots/trellis/pull/242.patch"},"body":"Picking up from #241, here's something that implements @louim's option 1, with both `files` and `templates` as @swalkinshaw suggested.\r\n\r\nBe warned: This isn't pretty, and it relies on the `regex_replace` filter. Pretty sure this is safe for Ansible >= 1.8, though. \r\n\r\nIs there a better way to do this? I couldn't figure out how to nest a `with_fileglob` inside a `with_dict` (or a `with_items`/`wordpress_sites.keys()`), so someone could break the task if one of their folder names doesn't match one of their site keys."},"comment":{"url":"https://api.github.com/repos/roots/trellis/issues/comments/120210374","html_url":"https://github.com/roots/trellis/pull/242#issuecomment-120210374","issue_url":"https://api.github.com/repos/roots/trellis/issues/242","id":120210374,"user":{"login":"fullyint","id":7338513,"avatar_url":"https://avatars.githubusercontent.com/u/7338513?v=3","gravatar_id":"","url":"https://api.github.com/users/fullyint","html_url":"https://github.com/fullyint","followers_url":"https://api.github.com/users/fullyint/followers","following_url":"https://api.github.com/users/fullyint/following{/other_user}","gists_url":"https://api.github.com/users/fullyint/gists{/gist_id}","starred_url":"https://api.github.com/users/fullyint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullyint/subscriptions","organizations_url":"https://api.github.com/users/fullyint/orgs","repos_url":"https://api.github.com/users/fullyint/repos","events_url":"https://api.github.com/users/fullyint/events{/privacy}","received_events_url":"https://api.github.com/users/fullyint/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T03:08:17Z","updated_at":"2015-07-10T03:08:17Z","body":"Here's an approach inspired by @louim's `with_pipe`. It passed some minimal testing.\r\n```yaml\r\n- name: Copy templates/includes to includes.d\r\n  template: src=\"{{ item }}\" dest=\"/etc/nginx/{{ item[:-3] }}\"\r\n  with_lines: \"cd ../templates && find includes.d -type f 2>/dev/null || :\"\r\n```\r\nNotes:\r\n- Still a bit messy.\r\n- One task only. I figured the template module could also handle regular files, so long as all filenames end in `.j2`. See any problems with this?\r\n- If there are no templates, the template task just skips.\r\n\r\nPotential problems: \r\n- Fails on incorrectly named path: `wordpress-setup/templates/includes.d/NOT-A-SITE/myconf.conf.j2`.\r\n- Removing a template from local `wordpress-setup/templates/includes.d` does not remove from remote server. Rather than remove a local template file, users may have to update the file's contents to be empty so that that template module would pick up on the changes.\r\n"}}