[chef] RE: Need help on printing output console from a command on the chef run


Chronological Thread 
  • From: Kapil Shardha < >
  • To: " " < >
  • Subject: [chef] RE: Need help on printing output console from a command on the chef run
  • Date: Thu, 1 May 2014 22:02:41 +0000
  • Accept-language: en-US

Have you tried using powershell_script resource?


Kapil


-------- Original message --------
From: Kimly
Date:05/01/2014 5:55 PM (GMT-05:00)
To:
Subject: [chef] Need help on printing output console from a command on the chef run

Hi,

I have a chef block code like this:

execute "Test to capture log" do
  command "powershell.exe -executionpolicy Bypass -command \"&
C:\\vagrant\\test.ps1\""
end

The test.ps1 will print out to the console something, while also logging it to
a log file.
When I do vagrant provision, how can I display what test.ps1 prints out at the
ON-GOING chef run?

I see that the 'execute' doesn't print out anything if it runs successfully,
otherwise it will shell out the error AT THE END OF THE RUN.

I also tried Chef::Mixin::ShellOut:

ruby_block "Running windows finishing script" do
  block do
    require 'chef/mixin/shell_out'
    extend Chef::Mixin::ShellOut
    Chef::Log.info "This will take a while to complete. Sit back and have some
beer."
    results = shell_out "powershell.exe -executionpolicy Bypass -command \"&
C:\\vagrant\\test.ps1\""
    Chef::Log.info "Output: #{ results.stdout }"
  end
end

And again, it still didn't print out anything until the end of the run.

My actual ps1 will install several middleware applications, takes about 10 mins
to complete, so I try to print out the output console while it's running to
show its progress.

Any help will be very appreciated.

~Kimly



This email and any accompanying documents may contain privileged or otherwise confidential information of, and/or is the property of Education Management Solutions, Inc. If you are not the intended recipient, please immediately advise the sender by reply email & delete the message & any attachments without using, copying or disclosing the contents. Thank you.



Archive powered by MHonArc 2.6.16.

§