knife bootstrap silent fail on windows 2008 x86 - ruby

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.

Related

Problem in generating a GNU screen session with ruby in Ubuntu 20.04

I have a workstation with Ubuntu 20.04 installed where I'm facing problem in generating GNU screen session inside a ruby script.
The ruby script has to generate a new GNU screen session with a custom name and attach the new session to a VNC server process.
Here is the code:
when 'screen'
sd=options[:screen_dir]
if sd then
FileUtils.mkdir_p(sd)
FileUtils.chmod 0700, sd
ENV['SCREENDIR']=sd
end
if !options.has_key?(:screen_exe) then
raise Error.new(:ExecuteRun, :option=>"screen_exe",:screen_dir=>sd, :mode => mode)
end
if !options.has_key?(:screen_conf) then
raise Error.new(:ExecuteRun, :option=>"screen_conf", :screen_dir=>sd, :mode => mode)
end
command="#{options[:screen_exe]} -L -c #{options[:screen_conf]} "+
" -dmS sessionname #{command}"
output=%x{#{command}}
status=$?.exitstatus
so1=%x{#{options[:screen_exe]} -ls}.
split.
find { |x| x =~ /^[0-9]+\.sessionname$/ }
if so1.kind_of?(Array) then
so=so1.map { |x| x.gsub(/^([0-9]+)\.sessionname$/,'\\1') }
else
so=[ so1.gsub(/^([0-9]+)\.sessionname$/,'\\1') ]
end
{ :output => output, :status => status, :pid => so[-1]}
After creating a folder where copying the screen_rc configuration and storing the GNU screen log, a new screen session is generated with logging (-L), a custom name (-S), detached mode (-d), skipping STY env variable (-m).
I introduced some debug messages (for example, screen ls command), which show me no generated sessions after the command is issued.
This behaviour is quite strange because the same ruby script works perfectly in the previous Ubuntu version (16.04 and 18.04). I noticed that the GNU screen version differs between these distributions: Ubuntu 16.04: 4.03.01 Ubuntu 18.04: 4.06.02 Ubuntu 20.04: 4.08.00
Also immediately after rebooting the workstation, the script works...but just for the first run...it seems that something remains pending, but there are no pending processes...
I found a temporary workaround downgrading the screen version to the 4.03.01 (Ubuntu 16.04), making the script working also in Ubuntu 20.04...but I would like to solve the problem with the newer version of GNU screen for the full porting of the script on the latest version of Ubuntu.
Thank you for the help in advance!

Jenkins Pipeline: build steps not running concurrently?

I'm having trouble with a Jenkins pipeline.
The thing is, it seems one of the steps is running in parallel with another (not intentionally):
I have something like:
...
step("build"){
bat [Visual Basic 6 compile command - vb6.exe file.vbp /outdir my/directory]
if(fileExists("my/directory/output.dll"){
println "SUCCESS"
}else{
error("error")
}
...
}
Ok, the problem is: it checks if the files exist before it's written by the compile command... If I put a sleep 10 before the condition, it always runs OK (for now), but obviously, I don't want to have a sleep command in my pipeline.
I don't know if I can control better the order os execution or if maybe the fault lies in the vb6.exe that creates a thread to write the output and then the main thread returns success before the output being written... does this make sense? Does anyone know how may I solve this problem?
My solution is to make the VB6 compilation step blocking.
This is what I run when working locally on my machine:
cmd /c VB6.exe /make someproject.vbp
And it is also the approach used by the Jenkins Visual Basic 6 plugin (I am the author). See this.

Unable to Run Meteor 1.1.0.3 Application Locally Windows 10 (Tasklist.exe)

I need some help please.
I just did a fresh install of Meteor 1.1.0.3 from the website using the windows installer. That worked just fine.
I then created one of the sample applications. That worked just fine.
The problem is when I try to run the app and the first package starts to download, I get an exception error. I have Googled this issue for a couple hours now and cannot find a solution.
Here is the CMD output Error:
C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\dev_bundle\lib\node_modules\fibers\
future.js:278
throw(ex);
^
Error: Couldn't run tasklist.exe: tasklist wasn't found on your system, it usually can be found at C:\Windows\System32\.
at Object.Future.wait (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\dev_bund
le\lib\node_modules\fibers\future.js:398:15)
at findMongoPids (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\tools\run-mon
go.js:120:16)
at findMongoAndKillItDead (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\tool
s\run-mongo.js:236:14)
at launchOneMongoAndWaitForReadyForInitiate (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.w
indows.x86_32\tools\run-mongo.js:360:7)
at launchMongo (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\tools\run-mongo
.js:612:7)
at [object Object]._.extend._startOrRestart (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.w
indows.x86_32\tools\run-mongo.js:712:19)
at [object Object]._.extend.start (C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86
_32\tools\run-mongo.js:670:10)
at C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\tools\run-all.js:199:26
- - - - -
at C:\Users\jwuli\AppData\Local\.meteor\packages\meteor-tool\1.1.4\mt-os.windows.x86_32\tools\run-mongo.js:73:24
at exithandler (child_process.js:654:7)
at ChildProcess.errorhandler (child_process.js:670:5)
at ChildProcess.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:818:12)
I am able to run tasklist.exe in any command window and see all my running process.
There is another user here that had the EXACT same issue but on Windows 7. What worked for him was opening the command prompt directly from the root directory of the project. This solution did not work for me.
That post is here: Other Post
I have also tried Powershell along with CMD both running as the Administrator.
Does anyone have any insight?
Thanks!
So after allot of research, and working with other similar platforms/frameworks. I found out that there are many dependencies that you need to install that are not listed in the normal documentation. Examples being, Python, Ruby for the Saas Gem. A ton of old windows C++ Distributabls.
As a Full Stack .NET developer all these concepts were new to me! Everything is working just fine now.

Extending Chef Windows Cookbook...DISM limitations

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.

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}")

Resources