当前位置: 动力学知识库 > 问答 > 编程问答 >

Why does Chef-Client have different outputs in PowerShell?

问题描述:

When I run Chef-Client in PowerShell and allow the process to output to the screen using the following command:

& Chef-Client -z -r "chef-cookbook"

I get this output:

[2014-11-10T07:20:40-08:00] WARN: No config file found or specified on command line, using command line options.

Starting Chef Client, version 11.16.4

resolving cookbooks for run list: ["chef-cookbook"]

Synchronizing Cookbooks:

- chef-cookbook

- powershell-automation

Compiling Cookbooks...

Converging 2 resources

Recipe: powershell-automation::Port_Configuration

* powershell_script[Port_Configuration] action run (skipped due to not_if)

Recipe: powershell-automation::IIS_InstallAutomation

* powershell_script[IIS_InstallAutomation] action run (skipped due to not_if)

Running handlers:

Running handlers complete

Chef Client finished, 0/0 resources updated in 43.69728 seconds

When I run the same command, but capture it to a variable, using the following command:

$chefOutput = & Chef-Client -z -r "chef-cookbook"

The $chefOutput variable contains:

[2014-11-10T07:23:01-08:00] WARN: No config file found or specified on command line, using command line options.

[2014-11-10T07:23:01-08:00] INFO: Auto-discovered chef repository at C:/Temp

[2014-11-10T07:23:01-08:00] INFO: Starting chef-zero on host localhost, port 8889 with repository at repository at C:/Temp

One version per cookbook

[2014-11-10T07:23:06-08:00] INFO: *** Chef 11.16.4 ***

[2014-11-10T07:23:06-08:00] INFO: Chef-client pid: 3364

[2014-11-10T07:23:37-08:00] INFO: Setting the run_list to [recipe[chef-cookbook]] from CLI options

[2014-11-10T07:23:37-08:00] INFO: Run List is [recipe[chef-cookbook]]

[2014-11-10T07:23:37-08:00] INFO: Run List expands to [chef-cookbook]

[2014-11-10T07:23:37-08:00] INFO: Starting Chef Run for XXXXX.XXX.XXX.XXX.com

[2014-11-10T07:23:37-08:00] INFO: Running start handlers

[2014-11-10T07:23:37-08:00] INFO: Start handlers complete.

[2014-11-10T07:23:37-08:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/XXXXX.XX.XX.XX.com/runs

[2014-11-10T07:23:37-08:00] INFO: Loading cookbooks [[email protected], [email protected]]

[2014-11-10T07:23:37-08:00] INFO: Processing powershell_script[Port_Configuration] action run (powershell-automation::Port_Configuration line 22)

[2014-11-10T07:23:37-08:00] INFO: Processing bash[Guard resource] action run (dynamically defined)

[2014-11-10T07:23:38-08:00] INFO: bash[Guard resource] ran successfully

[2014-11-10T07:23:38-08:00] INFO: Processing powershell_script[IIS_InstallAutomation] action run (powershell-automation::IIS_InstallAutomation line 16)

[2014-11-10T07:23:43-08:00] INFO: Chef Run complete in 6.346486 seconds

[2014-11-10T07:23:43-08:00] INFO: Running report handlers

[2014-11-10T07:23:43-08:00] INFO: Report handlers complete

Why does this discrepancy between outputs happen?

Note: I am seeing that the output in the variable also contains the time stamps and INFO tags for each line. Based on this, I believe this is something to do with how Chef outputs vs something to do with PowerShell.

网友答案:

It checks if stdout is a TTY.

分享给朋友:
您可能感兴趣的文章:
随机阅读: