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


Chronological Thread 
  • From: Kimly Heler < >
  • To: " " < >
  • Subject: [chef] Re: RE: Re: RE: Need help on printing output console from a command on the chef run
  • Date: Thu, 1 May 2014 16:31:14 -0700

Hi Kapil, so I thought about it just now, using locate_sysnative_cmd in powershell_script resource, which I never tried before.

But turned out powershell_script acts similar to execute, which didn't print out anything when it ran successfully:

[2014-05-01T23:27:02+00:00] INFO: powershell_script[Running windows finishing] ran successfully
[2014-05-01T23:27:02+00:00] INFO: Chef Run complete in 0.921875 seconds



On Thu, May 1, 2014 at 3:41 PM, Kapil Shardha < " target="_blank"> > wrote:

 

I was wondering if you have tried using powershell_script resources and “copied” your ps1 file content in it.  Something like this:

 

 

Powershell_resource “InstallSomething” do

                code <<-EOH

               

                <Content of your ps1 file>

 

                EOH

end

 

 

 

 

 

 

I had problem with powershell_script in my production provision as it confused between 32bit and 64bit powershell or something like that, causing it to unable to call the ps1 script, wasn't exactly sure the cause. 

 

I have to use locate_sysnative_cmd("powershell.exe") and it did the trick.

The funny thing is my vagrant worked just fine with or without the trick.

 

Have you tried using powershell_script resource?

 

 

Kapil



-------- Original message --------
From: Kimly
Date:05/01/2014 5:55 PM (GMT-05:00)
To: " target="_blank">
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.




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.

§