Skip to content
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

Install .NET framework via powershell through shell provider not working #181

Closed
cdenneen opened this issue Apr 8, 2014 · 13 comments
Closed

Comments

@cdenneen
Copy link

cdenneen commented Apr 8, 2014

Vagrant 1.5.2
Vagrant-Windows 1.6.0
Virtualbox 4.3.10

I've published my configuration and steps used to build basebox:

https://github.com/cdenneen/vagrant-windows-build/

Does anyone know if there is a debug for shell provision or for winrm that would help debug?

setup_requirements.cmd runs but .NET doesn't install properly but if I run the same cmd via GUI it works just fine.

I believe I've followed all the WinRb/vagrant-windows setup requirements for Vagrantfile and Basebox steps but still no luck.

Please let me know what other detail I can provide.

$ vagrant up                                                                                            
WARNING: Could not load IOV methods. Check your GSSAPI C library for an update
WARNING: Could not load AEAD methods. Check your GSSAPI C library for an update
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.1
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'windows-server-2008-r2-eval'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: Lab1_default_1396622969283_50281
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 5985 => 5985 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /Users/chris/src/lab/Lab1
    default: /_templates => /Users/chris/src/lab/Lab1/resources/templates/_templates
    default: /tmp/vagrant-puppet-1/modules-0 => /Users/chris/src/lab/Lab1/puppet/modules
    default: /tmp/vagrant-puppet-1/manifests => /Users/chris/src/lab/Lab1/puppet/manifests
    default: /ProgramData/PuppetLabs/puppet/etc/modules => /Users/chris/src/lab/Lab1/puppet/box_modules
==> default: Running provisioner: shell...

C:\Users\vagrant>echo 'Ensuring .NET 4.0 is installed'
'Ensuring .NET 4.0 is installed'
Creating folder 'c:\vagrant\resources\NetFx4'
Downloading 'http://download.microsoft.com/download/5/6/2/562A10F9-C9F4-4313-A044-9C94E0A8FAC8/dotNetFx40_Client_x86_x64.exe' to 'c:\vagrant\resources\NetFx4\dotNetFx40.exe'
Installing 'c:\vagrant\resources\NetFx4\dotNetFx40.exe'

C:\Users\vagrant>echo 'Ensuring Chocolatey is Installed'
'Ensuring Chocolatey is Installed'
PATH environment variable does not have 'C:\Chocolatey\bin' in it. Adding...

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----          4/4/2014  10:53 AM            chocInstall
Downloading http://chocolatey.org/api/v2/package/chocolatey/ to C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip
Download 7Zip commandline tool
Downloading http://chocolatey.org/7za.exe to C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\7za.exe
Extracting C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as a User Environment variable and setting it to 'C:\Chocolatey'
We are setting up the Chocolatey repository for NuGet packages that should be at the machine level. Think executables/application packages, not library packages.
That is what Chocolatey NuGet goodness is for. The repository is set up at 'C:\Chocolatey'.
The packages themselves go to 'C:\Chocolatey\lib' (i.e. C:\Chocolatey\lib\yourPackageName).
A batch file for the command line goes to 'C:\Chocolatey\bin' and points to an executable in 'C:\Chocolatey\lib\yourPackageName'.

Creating Chocolatey NuGet folders if they do not already exist.

d----          4/4/2014  10:53 AM            bin
d----          4/4/2014  10:53 AM            lib
d----          4/4/2014  10:53 AM            chocolateyinstall
Copying the contents of 'C:\Users\vagrant\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateyInstall' to 'C:\Chocolatey'.
Creating 'C:\Chocolatey\bin\chocolatey.bat' so you can call 'chocolatey'.
Creating 'C:\Chocolatey\bin\choco.bat' so you can call 'choco'.
Creating 'C:\Chocolatey\bin\cinst.bat' so you can call 'choco install' from a shortcut of 'cinst'.
Creating 'C:\Chocolatey\bin\cup.bat' so you can call 'choco update' from a shortcut of 'cup'.
Creating 'C:\Chocolatey\bin\cuninst.bat' so you can call 'choco uninstall' from a shortcut of 'cuninst'.
Creating 'C:\Chocolatey\bin\clist.bat' so you can call 'choco list' from a shortcut of 'clist'.
Creating 'C:\Chocolatey\bin\cver.bat' so you can call 'choco version' from a shortcut of 'cver'.
Creating 'C:\Chocolatey\bin\cpack.bat' so you can call 'choco pack' from a shortcut of 'cpack'.
Creating 'C:\Chocolatey\bin\cpush.bat' so you can call 'choco push' from a shortcut of 'cpush'.
User PATH already contains either 'C:\Chocolatey\bin' or '%DIR%..\bin'
Processing choco.bat to make it portable
Processing chocolatey.bat to make it portable
Processing cinst.bat to make it portable
Processing clist.bat to make it portable
Processing cpack.bat to make it portable
Processing cpush.bat to make it portable
Processing cuninst.bat to make it portable
Processing cup.bat to make it portable
Processing cver.bat to make it portable
Chocolatey is now ready.
You can call chocolatey from anywhere, command line or powershell by typing chocolatey.
Run chocolatey /? for a list of functions.
You may need to shut down and restart powershell and/or consoles first prior to using chocolatey.
If you are upgrading chocolatey from an older version (prior to 0.9.8.15) and don't use a custom chocolatey path, please find and delete the C:\NuGet folder after verifying that C:\Chocolatey has the same contents (minus chocolateyinstall of course).
Ensuring chocolatey commands are on the path
Chocolatey (v0.9.8.23) is installing 'chocolatey' and dependencies. By installing you accept the license for 'chocolatey' and each dependency you are installing.
Execution of NuGet not detected. Please make sure you have .NET Framework 4.0 installed and are passing arguments to the install command.
Command 'install' failed (sometimes this indicates a partial failure). Additional info/packages: chocolatey
Reading environment variables from registry. Please wait... Done.
@sneal
Copy link
Member

sneal commented Apr 8, 2014

You need to use a scheduled task to elevate to true admin privileges. The Chef provisioners in vagrant-windows do this automatically for you, the others do not.

@sneal sneal closed this as completed Apr 8, 2014
@cdenneen
Copy link
Author

cdenneen commented Apr 8, 2014

@sneal I've gone over this with @ferventcoder and it actually appears to work on some baseboxes but not others... (same exact powershell script and Vagrantfile) so it appears to possibly be more of locking down the exact steps for configuring a winrm basebox properly. @ferventcoder's basebox includes ssh so the thought is maybe the script is working on his because its using ssh vs winrm? Trying to properly diagnose this for consistent basebox builds.
chocolatey/puppet-chocolatey-handsonlab#5
So you think using scheduled task is still the answer here?
Any idea when the other provisioners will support elevated privs? Documentation appears that elevated is default.

@sneal
Copy link
Member

sneal commented Apr 8, 2014

Using SSH is going to behave completely differently than WinRM - security, environment, and limitations. For non-trivial software installs SSH is even more problematic than WinRM.

If you want installers to behave like they do when running locally on the box the most reliable and consistent way is to use a scheduled task - regardless of transport.

@cdenneen
Copy link
Author

cdenneen commented Apr 8, 2014

ok but since it works on some base boxes and doesn't on others there has to
be a difference being met in the vagrant-windows requirements that's
unclear. anyone able to pull down that repo and help me understand the
underlying issue with the basebox? (base_setup.ps1 as you see handles all
the requirements so there must be something missing)

@sneal
Copy link
Member

sneal commented Apr 8, 2014

I use Packer to build my base boxes. The Autounattend.xml here does something very similar to what your base_setup.ps1 script does.

I haven't seen a consistent way to install all Windows software over SSH or WinRM without the scheduled task trickery. If you figure out a better way that would be awesome.

@ferventcoder
Copy link
Contributor

I also shut off UAC. Perhaps that's the difference?

@ferventcoder
Copy link
Contributor

It appears you are installing .net framework 4.0. The next version of choco will install it automatically. It should be out soon. Be aware that it will assert privileges if UAC is turned on. So it's likely to fail in an automated fashion unless you have UAC turned off.

_sigh_ - UAC was built to be secure but there is no sudo, so it's somewhat useless for those who would script installation.

@cdenneen
Copy link
Author

cdenneen commented Apr 9, 2014

@ferventcoder the base_setup.ps1 disables UAC along with complex passwords and a bunch of other things https://github.com/cdenneen/vagrant-windows-build/blob/master/base_setup.ps1

@ferventcoder
Copy link
Contributor

Dumb question from me, is there a reboot after UAC is disabled?

@cdenneen
Copy link
Author

cdenneen commented Apr 9, 2014

bottom of the ps1 it restarts the computer... then i create basebox...

@ferventcoder
Copy link
Contributor

@cdenneen I just starred that. I need some of those items to packerize my boxes :)

@cdenneen
Copy link
Author

cdenneen commented Apr 9, 2014

@ferventcoder well maybe looking at that you can see something I missed to make my basebox like yours (that works with .NET ps1 install?)... I do a base install of windows, run that script (actually going to modify that to do the administrator -> vagrant user rename and password) and create box.

@ferventcoder
Copy link
Contributor

I don't yet see what could cause it unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants