From ae6dae2726a1756105dcbd1fcabb6f87bd6a620d Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 27 Sep 2017 16:02:18 -0700 Subject: [PATCH] add quoteless option to sudo example --- website/source/docs/provisioners/shell.html.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/source/docs/provisioners/shell.html.md b/website/source/docs/provisioners/shell.html.md index 12491dc51..77b9a7659 100644 --- a/website/source/docs/provisioners/shell.html.md +++ b/website/source/docs/provisioners/shell.html.md @@ -123,6 +123,12 @@ Some operating systems default to a non-root user. For example if you login as The `-S` flag tells `sudo` to read the password from stdin, which in this case is being piped in with the value of `packer`. +The above example won't work if your environment vars contain spaces or single quotes; in these cases try removing the single quotes: + +``` text +"echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}" +``` + By setting the `execute_command` to this, your script(s) can run with root privileges without worrying about password prompts.