{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/550","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/550/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/550/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/550/events","html_url":"https://github.com/hashicorp/terraform/issues/550","id":48037143,"number":550,"title":"Add support to remote-exec for calls with \"sudo\" mode","user":{"login":"cbrinker","id":449338,"avatar_url":"https://avatars.githubusercontent.com/u/449338?v=3","gravatar_id":"","url":"https://api.github.com/users/cbrinker","html_url":"https://github.com/cbrinker","followers_url":"https://api.github.com/users/cbrinker/followers","following_url":"https://api.github.com/users/cbrinker/following{/other_user}","gists_url":"https://api.github.com/users/cbrinker/gists{/gist_id}","starred_url":"https://api.github.com/users/cbrinker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbrinker/subscriptions","organizations_url":"https://api.github.com/users/cbrinker/orgs","repos_url":"https://api.github.com/users/cbrinker/repos","events_url":"https://api.github.com/users/cbrinker/events{/privacy}","received_events_url":"https://api.github.com/users/cbrinker/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hashicorp/terraform/labels/enhancement","name":"enhancement","color":"d4c5f9"},{"url":"https://api.github.com/repos/hashicorp/terraform/labels/provisioner/remote-exec","name":"provisioner/remote-exec","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-11-07T01:24:00Z","updated_at":"2015-10-22T14:36:16Z","closed_at":null,"body":"I am coming to terraform from an ansible background. Ansible has a really slick way of specifying certain actions/scripts that need to be run with elevated privileges that the ssh client doesn't have by default. You can see a nice example at:\r\n\r\nhttp://docs.ansible.com/playbooks_intro.html\r\n```\r\n---\r\n- hosts: webservers\r\n  remote_user: yourname\r\n  sudo: yes\r\n  sudo_user: postgres\r\n```\r\n\r\nI have many commands that I need to run as root (at least until I get Packer to pre-run these into images) The only way I can convince remote-exec to run all commands with root privs via sudo is something like this:\r\n```\r\n#!/bin/bash\r\nsudo -s \"\r\necho 'something' >>/etc/hosts\r\n ... many more things ...\r\n\"\r\n```\r\nbut the downside of this technique are that I don't get to see the STDOUT of the commands being executed also I feel like this is the first steps down into shell quoting hell.\r\n\r\nIs there an easier way to do what I need with the existing remote-exec? or is it trivial to add a sudo/sudo_user attribute to remote-exec?\r\n\r\nThanks,\r\nChris \r\n"},"comment":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/comments/150243652","html_url":"https://github.com/hashicorp/terraform/issues/550#issuecomment-150243652","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/550","id":150243652,"user":{"login":"OleksandrBerchenko","id":11785287,"avatar_url":"https://avatars.githubusercontent.com/u/11785287?v=3","gravatar_id":"","url":"https://api.github.com/users/OleksandrBerchenko","html_url":"https://github.com/OleksandrBerchenko","followers_url":"https://api.github.com/users/OleksandrBerchenko/followers","following_url":"https://api.github.com/users/OleksandrBerchenko/following{/other_user}","gists_url":"https://api.github.com/users/OleksandrBerchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/OleksandrBerchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OleksandrBerchenko/subscriptions","organizations_url":"https://api.github.com/users/OleksandrBerchenko/orgs","repos_url":"https://api.github.com/users/OleksandrBerchenko/repos","events_url":"https://api.github.com/users/OleksandrBerchenko/events{/privacy}","received_events_url":"https://api.github.com/users/OleksandrBerchenko/received_events","type":"User","site_admin":false},"created_at":"2015-10-22T14:36:16Z","updated_at":"2015-10-22T14:36:16Z","body":"I would like this as well."}}