{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/11012","labels_url":"https://api.github.com/repos/ansible/ansible/issues/11012/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/11012/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/11012/events","html_url":"https://github.com/ansible/ansible/issues/11012","id":76420867,"number":11012,"title":"Copy content from variable to file","user":{"login":"flmmartins","id":4236460,"avatar_url":"https://avatars.githubusercontent.com/u/4236460?v=3","gravatar_id":"","url":"https://api.github.com/users/flmmartins","html_url":"https://github.com/flmmartins","followers_url":"https://api.github.com/users/flmmartins/followers","following_url":"https://api.github.com/users/flmmartins/following{/other_user}","gists_url":"https://api.github.com/users/flmmartins/gists{/gist_id}","starred_url":"https://api.github.com/users/flmmartins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flmmartins/subscriptions","organizations_url":"https://api.github.com/users/flmmartins/orgs","repos_url":"https://api.github.com/users/flmmartins/repos","events_url":"https://api.github.com/users/flmmartins/events{/privacy}","received_events_url":"https://api.github.com/users/flmmartins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-14T16:50:32Z","updated_at":"2015-05-15T17:35:24Z","closed_at":null,"body":"Hello All,\r\n\r\nI need to put a vaulted file in a file inside my server. \r\nAs this is not yet supported by ansible, I have looked many solutions for these like using lookups (https://github.com/ansible/ansible/pull/8110 - it didn't work), using template files (http://stackoverflow.com/questions/22773294/how-to-upload-encrypted-file-using-ansible-vault - generate new lines in the file) and with copy module as described in previous link.\r\nWith the copy module using the long sintax (link above) was the way I found to pass a vaulted variable b but I need my destination to use a path provided by another variable like this:\r\n\r\n(Declared in a vars)\r\napp_path: /opt\r\n\r\n```bash\r\n - copy:\r\n      content: \"{{ mycert }}\"\r\n      dest: {{app_path}}/config/public.pem\r\n```\r\nInfortunately I was not able to use {{app_path}} with destination WITH THE LONG SINTAX. I tried the following:\r\n\r\n```bash\r\n - copy:\r\n      content: \"{{ mycert }}\"\r\n      dest: \"{{app_path}}\"/config/public.pem\r\n```\r\n\r\nAnd\r\n\r\n```bash\r\n - copy:\r\n      content: \"{{ mycert }}\"\r\n      dest: \"{{app_path}}/config/public.pem\"\r\n```\r\n\r\nNone of  those worked. Does someone knows why is that? I am running Ansible 1.7.2"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/102465219","html_url":"https://github.com/ansible/ansible/issues/11012#issuecomment-102465219","issue_url":"https://api.github.com/repos/ansible/ansible/issues/11012","id":102465219,"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":"2015-05-15T17:35:24Z","updated_at":"2015-05-15T17:35:24Z","body":"First i would advise using the template module instead, copy's content was not meant to support anything but trivial values. \r\n\r\n- the first example will not work because YAML will see the initial '{' and expect a dictionary\r\n- the 2nd will not work because when you start a YAML value with a quote, the whole value must be contained in that quote pair.\r\n- the 3rd 'should work' at least for dest\r\n\r\nWe need more info for debuggin as 'does not work' can mean many things, please provide specific errors"}}