Thanks Megan! I am new to Packer, like as in I just started using it today 
so not sure I would be the best person to test at the moment. I will take a 
look at this though.


On Friday, May 4, 2018 at 1:05:27 PM UTC-4, Megan Marsh wrote:
>
> Okay, trying one more time, now without the packer binary which Gmail 
> decided was too dangerous to send.
>
> _____
>
> I'm sorry to say it's not currently possible.  The shell-local 
> post-processor has some hardcoded assumptions that the shell in question is 
> sh:  
> https://github.com/hashicorp/packer/blob/4dcf9d760b2fd549ddad85837e78e0ed64620a5e/post-processor/shell-local/communicator.go#L16
>
> But all is not lost. I have a pretty hefty rewrite of the code used for 
> the shell-local provisioner and post-processors scheduled for the 1.3.0 
> release (https://github.com/hashicorp/packer/pull/5956) which, among 
> other things, should make this possible. I've attached a windows build of 
> that PR to that PR and you'll find it at the above link if you'd like to 
> test it out; I could use some community validation that it solves these 
> kinds of less common cases.
>
> Example of running a powershell script on windows:
> Required customizations: env_var_format and execute_command
>
>       {
>           "type": "shell-local",
>           "environment_vars": ["SHELLLOCALTEST=ShellTest4"],
>           "execute_command": ["powershell.exe", "{{.Vars}} {{.Script}}"],
>           "env_var_format": "$env:%s=\"%s\"; ",
>           "script": "./scripts/example_ps.ps1"
>       }
>
> Example of running a powershell script on windows as "inline":
> Required customizations: env_var_format, tempfile_extension, and 
> execute_command
>
>       {
>           "type": "shell-local",
>           "tempfile_extension": ".ps1",
>           "environment_vars": ["SHELLLOCALTEST=ShellTest5"],
>           "execute_command": ["powershell.exe", "{{.Vars}} {{.Script}}"],
>           "env_var_format": "$env:%s=\"%s\"; ",
>           "inline": ["write-output $env:SHELLLOCALTEST"]
>       }
>
> Thanks!
>
>
> On Fri, May 4, 2018 at 10:02 AM, Megan Marsh <[email protected] 
> <javascript:>> wrote:
>
>> Turns out google blocked me attaching the packer binary; I'll attach it 
>> to the PR I linked above on GitHub
>>
>> On Fri, May 4, 2018 at 10:01 AM, Megan Marsh <[email protected] 
>> <javascript:>> wrote:
>>
>>> I'm sorry to say it's not currently possible.  The shell-local 
>>> post-processor has some hardcoded assumptions that the shell in question is 
>>> sh:  
>>> https://github.com/hashicorp/packer/blob/4dcf9d760b2fd549ddad85837e78e0ed64620a5e/post-processor/shell-local/communicator.go#L16
>>>
>>> But all is not lost. I have a pretty hefty rewrite of the code used for 
>>> the shell-local provisioner and post-processors scheduled for the 1.3.0 
>>> release (https://github.com/hashicorp/packer/pull/5956) which, among 
>>> other things, should make this possible. I've attached a windows build of 
>>> that PR if you'd like to test it out; I could use some community validation 
>>> that it solves these kinds of less common cases.
>>>
>>> Example of running a powershell script on windows:
>>> Required customizations: env_var_format and execute_command
>>>
>>>       {
>>>           "type": "shell-local",
>>>           "environment_vars": ["SHELLLOCALTEST=ShellTest4"],
>>>           "execute_command": ["powershell.exe", "{{.Vars}} {{.Script}}"],
>>>           "env_var_format": "$env:%s=\"%s\"; ",
>>>           "script": "./scripts/example_ps.ps1"
>>>       }
>>>
>>> Example of running a powershell script on windows as "inline":
>>> Required customizations: env_var_format, tempfile_extension, and 
>>> execute_command
>>>
>>>       {
>>>           "type": "shell-local",
>>>           "tempfile_extension": ".ps1",
>>>           "environment_vars": ["SHELLLOCALTEST=ShellTest5"],
>>>           "execute_command": ["powershell.exe", "{{.Vars}} {{.Script}}"],
>>>           "env_var_format": "$env:%s=\"%s\"; ",
>>>           "inline": ["write-output $env:SHELLLOCALTEST"]
>>>       }
>>>
>>> Thanks!
>>> Megan
>>>
>>>
>>> On Fri, May 4, 2018 at 9:49 AM, Dan Franciscus <[email protected] 
>>> <javascript:>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> Can someone give me an example of a proper way to run a PowerShell 
>>>> script for a post processor on Windows? This does not seem to be working...
>>>>
>>>> "post-processors": [
>>>> {
>>>> "type": "shell-local",
>>>> "execute_command": "PowerShell -File A:/Test.ps1",
>>>> "inline": ["Test"]
>>>> }
>>>> ],
>>>>
>>>> -- 
>>>> This mailing list is governed under the HashiCorp Community Guidelines 
>>>> - https://www.hashicorp.com/community-guidelines.html. Behavior in 
>>>> violation of those guidelines may result in your removal from this mailing 
>>>> list.
>>>>  
>>>> GitHub Issues: https://github.com/mitchellh/packer/issues
>>>> IRC: #packer-tool on Freenode
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Packer" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected] <javascript:>.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/packer-tool/a641b13a-dee6-44ae-9b6d-4c0623bd8039%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/packer-tool/a641b13a-dee6-44ae-9b6d-4c0623bd8039%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/5d254787-7328-48a8-bf45-dbbbfaa6674b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to