chef-boneyard / chef-provisioning

A library for creating machines and infrastructures idempotently in Chef.
Apache License 2.0
524 stars 164 forks source link

Provisioning - Install.ps1 file has syntax errors #528

Open kalapakim opened 8 years ago

kalapakim commented 8 years ago

I created an issue in teh Chef Forum, but I"m not sure if it's something that is being caused by this cookbook or by a change that was made on Chef's side..

Here is the link to the issue in the forum.. https://discourse.chef.io/t/provisioning-install-ps1-file-has-syntax-errors/8884

When I run a chef-run, I see the error as:

[Rel92-Test-agt1] At C:\chef\install.ps1:56 char:13
                  +   if ($pA256($src) {
                  +             ~
                  Unexpected token '(' in expression or statement.
                  At C:\chef\install.ps1:56 char:13
                  +   if ($pA256($src) {
                  +             ~
                  Missing closing ')' after expression in 'if' statement.
                  At C:\chef\install.ps1:56 char:20
                  +   if ($pA256($src) {
                  +                    ~
                  Unexpected token '{' in expression or statement.
                  At C:\chef\install.ps1:51 char:29
                  + Function Install-Chef($msi) {
                  +                             ~
                  Missing closing '}' in statement block.
                      + CategoryInfo          : ParserError: (:) [], ParseException
                      + FullyQualifiedErrorId : UnexpectedToken

I Check the script locally on the node and the syntax is in fact bad, I deleted it and ran it again, and the same script is downloaded. This script is generated via the Chef-Provisioning cookbook:

https://github.com/chef/chef-provisioning/blob/73858aff021dd1830b38ff33b693c5f7f5c3825b/lib/chef/provisioning/convergence_strategy/install_msi.rb

but I'm not sure this is because of that cookbook or the generator for the scrpt that is run on line 39

install_command = Mixlib::Install::ScriptGenerator.new(chef_version, true, opts).install_command

smurawski commented 8 years ago

Adding context from the Discourse thread - install.ps1 that was generated - https://gist.github.com/kalapakim/9c1fe6ed587f769d6a50c105d10c1419 - has a bunch of mangled/overwritten function definitions.

@kalapakim what OS and version are you using for your workstation and what OS and version are you using chef provisioning against?

kalapakim commented 8 years ago

my workstation is windows 7, the server is windows 2012...weird thing is, I was testing this in test kitchen and I had no issues...and I just got done running a provisioning run and built out 11 servers, no issue...but soon as I attempted this recipe, it started getting the error

kalapakim commented 8 years ago

I checked another server's install.ps1 file, which was done just a few minutes before I attempted to run the new recipe on these and it doesn't have the same syntax errors..

Function Install-Chef($msi) {
  Log "Installing Chef Omnibus package $msi"
  $p = Start-Process -FilePath "msiexec.exe" -ArgumentList "/qn /i $msi" -Passthru -Wait
  $p.WaitForExit()

  if ($p.ExitCode -ne 0) { throw "msiexec was not successful. Received exit code $($p.ExitCode)" }

  Remove-Item $msi -Force
  Log "Installation complete"
}
smurawski commented 8 years ago

@kalapakim what provisioning driver are you using? Where the 11 successful servers built from the same base image as the failing 12th?

kalapakim commented 8 years ago

update, the next day, I no longer got that error...seems to be fine now