Extending Chef Windows Cookbook...DISM limitations - windows

I'm attempting to install .NET 3.5 framework on WinServer 2012, using Chef.
The ms_dotnet35 cookbook however, doesn't support WinServer 2012.
So I've copied the code it uses in the cookbook to install (from here) (pardon the formatting):
if platform?('windows')
unless File.exists?('C:/Windows/Microsoft.NET/Framework/v3.5')
windows_feature 'NetFx3' do
action :install
end
end
else Chef::Log.warn('Microsoft Framework .NET 3.5 can only be installed on the Windows platform.')
end
However, there is a snag. When Chef runs, "windows_feature" passes the following commandline:
C:\Windows\sysnative\dism.exe /online /enable-feature /featurename:NetFx3 /norestart
It turns out that on WinServer 2012, you need to pass the "/all" argument or you'll get an "A required parent feature may not be enabled." exception (from here)
So now I am looking at the code for "windows_feature" in the windows cookbook (from here):
def install_feature(name)
# return code 3010 is valid, it indicates a reboot is required
shell_out!("#{dism} /online /enable-feature /featurename:#{#new_resource.feature_name} /norestart", {:returns => [0,42,127,3010]})
end
..where we find the actual call to DISM.
What is the recommended way for me to extend this? Should I just copy the shell_out call and hack the DISM line to get this to work?
I'm new to Chef and want to be following the best practice/correct paradigm. I don't understand why the current implementation of windows_feature doesn't provide a way to enter optional arguments like "/all".

I ended up creating a new recipe in a new cookbook to handle installing .Net Framework 3.5 on Windows Server 2012.
I was able to find the needed files (since I don't have an install disk, I'm on Azure) by dowloading an eval ISO from here.
After mounting the ISO I zipped the entire ..\Sources\sxs folder.
my one execute command looks like this:
execute "install_net35" do
command "C:/Windows/sysnative/dism.exe /online /enable-feature /all /featurename:NetFx3 /norestart /limitaccess /source:C:/tempdirectory/sxs"
...where "C:/tempdirectory/sxs" is the unzipped file.
I also wrapped the execution in a check for Windows Server 2012:
if win_version.windows_server_2012? || win_version.windows_server_2012_r2?
..and do a check to see if the framework is already installed (to ensure idempotence):
unless File.exists?('C:/Windows/Microsoft.NET/Framework/v3.5')

According to the documentation I believe you should be able to the following (haven't tested it - so feel free to correct me!)
if platform?('windows')
windows_feature 'NetFx3' do
action :install
all true
end
else
Chef::Log.warn('Microsoft Framework .NET 3.5 can only be installed on the Windows platform.')
end
https://github.com/opscode-cookbooks/windows
all: Boolean. Optional. Default: false. DISM provider only. Forces all dependencies to be installed.
The unless file exists isn't necessary, windows_feature only installs unless installed anyway.

Related

RegAsm.exe unable to register Dll through installshield 2016

We have installshield 2016 and inside this we are running installer script. That script is call through custom action.
So we are written following commnad to register "mydll.dll" as below mentioned command,
C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe /codebase mydll.dll
The above command works perfectly fine when run manually through command prompt with administrative access.But fails through installer created using installshield script custom action.
To run command we use LaunchApplicationAndWait() and LaunchApplication() functions as
strcmd = "path to cmd.exe" + "cmd.exe"
strcmdopt = "path to regasm.exe" + "regasm.exe " + /codebase + path and name of dll
ret = LaunchApplication(strcmd, strcmdopt, windir, sw_normal, infinite, LAAW_OPTION_WAIT | LAAW_OPTION_SHELLEXECUTE)
similarly
ret = LaunchApplicationAndWait(strcmd ,strcmdopt,LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN)
My Question is why both command not work when run through installshield custom action scripts
Is the dll distributed with the installation? if so, is the file present in the installdir (or wherever) when the script is called? Maybe add some msg box for debug purposes to see if this condition is met.
Im using deferred custom action to register .dll via regasm and it works just fine.
You shouldn't be calling Regasm during the install. You should put the DLL as a key file in it's own component and set the COM Interop = True attribute. This will cause InstallShield to perform a regasm /regfile during the build and take the output and dynamically author it into the Registry table. During the install, MSI will simply copy the file and apply the registry entries and your done.
Note: Per MSDN doco custom functions are not called during regasm /regfile so if you are doing any wierd self registration inside your class you'll need to author that into the installer.

knife bootstrap silent fail on windows 2008 x86

I use knife bootstrap on windows 2008 x86 server is silent fail.
It created windows batch file, but the batch file not executed and return code is 0.
the version info is
knife-windows version:1.4.1
winrm version:1.8.1
and after digging, I think found that. on knife-windows source code lib/chef/knife/winrm_session.rb "relay_command" method
remote_id = #winrm_session.open_shell
command_id = #winrm_session.run_command(remote_id, command)
=> it's not run batch file. just exit code is 0, and run other command is OK
#winrm_session.create_executor do |executor|
executor.run_cmd(cmd) do |stdout, stderr|
Chef::Log.info(cmdstdout)
Chef::Log.error(cmdstderr)
end
end
=> it's ok to run batch file. but lt's bad idea because can't get real time log
sound like the it is winrm_session run_command bug. but I'm not sure.
how to fix this?
thanks.
It was fixed via https://github.com/chef/knife-windows/pull/389
so when update knife-windows to newest version, It will be OK.

How to perform an unattended installation of Sitecore?

My team is attempting to perform an automated installation of Sitecore via Salt using the Sitecore executable. We prefer to use the .exe over a manual installation of the zip package because the installation wizard handles registering Sitecore as an installed program by modifying the registry. This would theoretically let Salt know that the "state" has been fulfilled.
When running the executable with the /? argument, the following list of options is displayed:
/? or /help : this help screen
/i : install (default)
/x : uninstall
/q : force silent (no UI) mode
/qb : force basic UI mode
/nq : force full UI mode
/nosplash : do not display splash screen
/Log : enable logging
/LogFile [path] : specify log file
/ConfigFile [path] : specify configuration file
/ExtractCab : extract embedded components
/DisplayCab : display a list of embedded components
/DisplayConfig : display a list of configurations
/ComponentArgs ["id|display_name":"value"...] : additional component args
/ControlArgs ["id":"value" ...] : additional control values
/CompleteCommandArgs [args] : additional complete command
Despite our best efforts, we are unable to find documentation on these arguments apart from the descriptions above. I think what we're after is a way to provide a config file to the executable (using the /ConfigFile argument) that contains the following information:
Install / uninstall
Installation type (full / client-only)
Instance name
Database credentials
Running the /DisplayConfig command only displays language options and that's about it.
Does anyone know how to provide a config to the executable and/or pass it the arguments it needs?
I wrote a blog post about the issue of getting the Sitecore installer automated:
http://jermdavis.wordpress.com/2014/04/24/unattended-installs-of-sitecore/
I think that might help you?
For anyone else who needs an answer to this, this is how me and Derek got it to work:
../salt-states/win/repo/sitecore/init.sls
Sitecore:
7.1:
installer: 'salt://win/repo/sitecore/Sitecore 7.1 rev. 130926.exe'
full_name: 'Sitecore 7.1 rev. 130926 - Sitecore130926'
reboot: False
install_flags: ' /q /ExtractCab && msiexec.exe /qn /i SupportFiles\exe\Sitecore.msi TRANSFORMS=":InstanceId1;:ComponentGUIDTransform1.mst" MSINEWINSTANCE=1 LOGVERBOSE=1 SC_LANG="en-US" SC_CLIENTONLY="1" SKIPINSTALLSQLDATA="1" SKIPUNINSTALLSQLDATA="1" SC_INSTANCENAME="Sitecore130926" SC_LICENSE_PATH="C:\inetpub\temp\sitecore_license.xml" SC_SQL_SERVER="SERVER" SC_DBPREFIX="Sitecore130926" SC_DBTYPE="MSSQL" INSTALLLOCATION="C:\Inetpub\wwwroot\Sitecore130926" SC_DATA_FOLDER="C:\Inetpub\wwwroot\Sitecore130926\Data" SC_NET_VERSION="4" SITECORE_MVC="1" SC_INTEGRATED_PIPELINE_MODE="1" SC_IISSITE_NAME="Sitecore130926" SC_IISAPPPOOL_NAME="Sitecore130926AppPool" SC_IISSITE_HEADER="local.domain.org" SC_IISSITE_PORT="80" SC_IISSITE_ID="2" SC_PREFIX_PHYSICAL_FILES="1" SC_SQL_SERVER_CONFIG_USER="USER" SC_SQL_SERVER_CONFIG_PASSWORD="PASSWORD" /l*+v "C:\inetpub\temp\SitecoreInstaller.log"'
uninstaller: 'salt://win/repo/sitecore/Sitecore 7.1 rev. 130926.exe'
uninstall_flags: ' /q /ExtractCab && msiexec.exe /qn /X{D0CB9951-0EC0-55B1-A2C8-4590B816E4EC}'
../salt-states/sitecore/init.sls
Sitecore:
pkg.installed:
- refresh: true
- require:
- file: C:\inetpub\temp\sitecore_license.xml
C:\inetpub\temp\sitecore_license.xml:
file.managed:
- source: salt://sitecore/license.xml
Add your sitecore license to ../salt-states/sitecore/license.xml
Thanks to JermDavis, this wasn't possible without your blog post!
Are you tied to using that tool or are you open to others? My team has had pretty great results with the SIM tool which comes directly from the Sitecore Marketplace. It has command line functionality as well as an API for more trickier installation setups. I consider this a borderline magical utility for Sitecore :)
https://marketplace.sitecore.net/en/Modules/Sitecore_Instance_Manager.aspx

CMake: download and run msi

Using kitware's CMake, is it possible to automatically download a Microsoft installer (MSI) file and execute it (on Windows, of course)?
It generally should be. However, clearly running the installer will block the CMake process until the user completes all the required inputs to the installer.
Here's an example for 7-zip's installer making use of file(DOWNLOAD ...) and execute_process:
set(DownloadedMsi ${CMAKE_BINARY_DIR}/7z920-x64.msi)
file(DOWNLOAD http://sourceforge.net/projects/sevenzip/files/7-Zip/9.20/7z920-x64.msi/download
${DownloadedMsi}
TIMEOUT 30
STATUS StatusVar
LOG LogVar
EXPECTED_HASH SHA1=4173fea2af9a595fa0be1ef8251f412229687be1)
message("\${StatusVar} - ${StatusVar}")
message("\${LogVar} - ${LogVar}\n\n\n")
execute_process(COMMAND cmd /c "${DownloadedMsi}"
RESULT_VARIABLE ResultVar
OUTPUT_VARIABLE OutputVar
ERROR_VARIABLE ErrorVar)
message("\${ResultVar} - ${ResultVar}")
message("\${OutputVar} - ${OutputVar}")
message("\${ErrorVar} - ${ErrorVar}")

What causes ClickOnce URLDownloadToCacheFile failed during installation?

I'm getting the following error when installing my ClickOnce application via firefox. It doesn't happen with IE on the same computer. I swear I've installed it via firefox before. This is a Windows 7 machine.
The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [ProcessorArchitecture] = Intel {string}
Property: [VersionNT] = 6.1.0 {version}
Running checks for package '.NET Framework 2.0 (x86)', phase BuildList
Running external check with command 'C:\Users\luke\AppData\Local\Temp\VSDEF1A.tmp\DotNetFX\dotnetchk.exe' and parameters ''
Process exited with code 1
Setting value '1 {int}' for property 'DotNetInstalled'
Reading value 'Version' of registry key 'HKLM\Software\Microsoft\Internet Explorer'
Read string value '8.0.7600.16385'
Setting value '8.0.7600.16385 {string}' for property 'IEVersion'
The following properties have been set for package '.NET Framework 2.0 (x86)':
Property: [DotNetInstalled] = 1 {int}
Property: [IEVersion] = 8.0.7600.16385 {string}
Running checks for command 'DotNetFX\instmsia.exe'
Result of running operator 'ValueExists' on property 'VersionNT': true
Result of checks for command 'DotNetFX\instmsia.exe' is 'Bypass'
Running checks for command 'DotNetFX\WindowsInstaller-KB893803-v2-x86.exe'
Result of running operator 'ValueExists' on property 'Version9x': false
Result of running operator 'VersionLessThan' on property 'VersionNT' and value '5.0.3': false
Result of running operator 'VersionGreaterThanOrEqualTo' on property 'VersionMsi' and value '3.0': true
Result of checks for command 'DotNetFX\WindowsInstaller-KB893803-v2-x86.exe' is 'Bypass'
Running checks for command 'DotNetFX\dotnetfx.exe'
Result of running operator 'ValueNotEqualTo' on property 'DotNetInstalled' and value '0': true
Result of checks for command 'DotNetFX\dotnetfx.exe' is 'Bypass'
'.NET Framework 2.0 (x86)' RunCheck result: No Install Needed
Launching Application.
URLDownloadToCacheFile failed with HRESULT '-2146697211'
Error: An error occurred trying to download 'http://croppy.lukehunter.net/download/croppy.application'.
The following is the howto from Microsoft, but this doesn't apply to firefox. There is no redirection happening either.
If a user has set Internet Explorer
Advanced Security option "Warn if
changing between secure and not secure
mode" on the deployment target
computer, and if the setup URL of the
ClickOnce application being installed
is redirected from a non-secure to a
secure site (or vice-versa), the
installation will fail because the
Internet Explorer warning interrupts
it.
Internet Explorer calls either LaunchApplication or ShOpenVerbApplication procedure from dfshim.dll behind the scenes, whereas Firefox plug-in (as well as a standard bootstrapper created by Visual Studio 2008-2010, which could also produce this rare error) uses a different, out of date technique to launch ClickOnce applications. (Note, that LaunchApplication requires at least .NET Framework 2 SP 2.)
To avoid such error one could redirect Internet Explorer to a deployment manifest (.application) and all other browsers to a custom installer (.exe) that would install .NET Framework if necessary and then call ShOpenVerbApplication.
Hmm, after using IE to install, then uninstalling, I was able to install via firefox again. Odd.
The following worked for me:
Within the local distribution package CLICK ONCE a web.config file was generated on line clientCache that was the problem, in which altered as follows for CHROME and IE8 and now run the file:
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
I've had this and it to resolve it was to disable the firewall. I sadly don't know what Firewall settings it was, I just disabled the lot and it ran/installed without issue.
After exhausting firewall options on this issue, I found that my excutable was pointing to the IP Address of the Application Server. When I changed the site deployment and consequently the executable to the FQDN of the server instead of the IP Address, the installer worked first time.
Simple Solution, on cmd execute setup.exe /URL=http://< Production  URL>/
Easy!

Resources