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


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

 

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

 

 

 

 

 

From: Kimly Heler [mailto:
Sent: Thursday, May 1, 2014 6:37 PM
To:
Cc:
Subject: [chef] Re: RE: Need help on printing output console from a command on the chef run

 

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.

 


On May 1, 2014, at 3:02 PM, Kapil Shardha < "> > wrote:

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.




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.

§