-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Packer 1.6.0 PowerShell Script is not recognized but runs OK #9400
Comments
Thanks for reaching out. We will take a look at what might be going on here. Does this issue occur in Packer 1.5.6? |
Hello again, I asked about 1.5.6 because 1.6.0 was just released so wanted to check if it was specific to the latest version. With that said, could you provide the full build log, stripped of any sensitive information, please. The provided error message indicates that Packer failed to find the environment variable setting script As of right now I am unable to reproduce this issue but the full debug log may help show what might be happening. Are there any other provisioners in your build configuration that run prior to the cleanup script? Thanks! |
Thanks for looking into this, I don't have 1.5.6 with me but I remember upgrading from 1.5 to 1.6 because I was having similar issues with that version. Here are few lines straight from the console after turning on
|
Hi @0ni0nrings thanks for the additional log information. Looking at the new info it looks like this error is occurring during the Powershell cleanup step. Packer's cleanup step will log any errors but continue executing, which explains why the error is only logged and the build continues. The first provisioner doesn't have this issue so it might be something specific to your I would check your script to ensure that it is not deleting all of the files in C:/Windows/Temp. If it is I would recommend narrowing its scope. Or if you don't want to spend much time changing your script you can pass the {
"type": "powershell",
"skip_clean": true,
"script": "./script/win_cleanup.ps1"
} Feel free to close this issue if the suggested next steps work for you . Cheers! |
OK, now I remember why I moved from 1.5.6 to 1.6, so here's what I did, I changed the content of clean up script to the command show below, simple command to create a directory
Running Packer with verbosity & you'll see from the logs that Packer doesn't identify the content type. I thought PowerShell provisioner can handle a PowerShell script without using special syntax. This is just an example of how PowerShell provisioner is handling a one liner script.
|
I keep having this same issue coming and going it seems. Packer 1.6.5
|
There seems to be a high degree of inconsistency when working with packer and PowerShell on windows, questioning if it is the right solution. |
I've seen this happen when there's a race condition -- winRM is available for Packer to connect to, but the powershell modules aren't all loaded. Adding a pause_before to your first provisioner should clear it up. |
Is what you are saying is that when packer creates a temp script file, to place the PowerShell code, it needs more time to complete the file creation, so if you put a pause_before: "10s" it might give it the extra time it needs making sure the file is there? If so, do you know what the default delay is? |
no, the "powershell modules" are a windows thing. Basically, windows isn't fully booted even though Packer can connect to it, and that causes problems. The default is no pause. But if you give it an arbitrary pause, that will give the vm time to finish booting. |
This fixed the issue for us; we had a cleanup script that was deleting all files from Can the Packer cleanup step be enhanced to indicate that |
@nywilken @SwampDragons I think this is also related hashicorp/packer-plugin-googlecompute#108 |
While
This is occurring on 1.11.2 of packer.
|
Sorry for double-posting comments but I found a work-around, for anyone else who stumbles across this via their internet search (as I did). The work-around is to install PowerShell manually and then use
This seems to stop the errors related to both the cleanup and vars scripts, as these error conditions appear to be specific to the PS version that's default installed on Win* images (a.k.a.: Windows PowerShell). |
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
Overview of the Issue
PowerShell Script will run & do the cleanup but the screen output shows RED message
Reproduction Steps
This is cleanup.ps1
Packer version
1.6.0
Simplified Packer Buildfile
Operating system and Environment details
Log Fragments and crash.log files
As above
Set the env var
PACKER_LOG=1
for maximum log detail.I would really like to see a full example of Packer configuring a Windows AMI for ports 5985 and 5986, not snippets but detailed examples with inline and scripts options. Using Packer has been a trouble so far as the documentation around WinRM is bite sized and incomplete.
The text was updated successfully, but these errors were encountered: