Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chefctl on windows doesn't produce logs in /var/chef/outputs #74

Closed
natewalck opened this issue Feb 7, 2019 · 3 comments
Closed

chefctl on windows doesn't produce logs in /var/chef/outputs #74

natewalck opened this issue Feb 7, 2019 · 3 comments

Comments

@natewalck
Copy link

natewalck commented Feb 7, 2019

When using chefctl on windows, I cannot get it to write out the log to C:\chef\outputs like it does on Linux/macOS.

This occurs on chef-client 14.10.9.
Here is the config:

lock_file 'C:/chef/chefctl.lock'
plugin_path 'C:/chef/chefctl_hooks.rb'
log_dir 'C:/chef/outputs'
default_chef_options ["--fatal-windows-admin-check"]
chef_options ["-c C:/chef/solo/solo.rb"]
chef_client 'C:/opscode/chef/bin/chef-client.bat'
lock_time 1800
max_retries 1
windows_subshell true

Here is the command:

C:\opscode\chef\embedded\bin\ruby.exe c:\chef\chefctl.rb -C C:\chef\chefctl-config.rb

And here is what ends up in C:\chef\outputs:

PS C:\chef\outputs> Get-Content chef.20190207.1115.1549556120.out
[2019-02-07 11:15:21 -0500] WARN chefctl: Deprecated: windows_subshell shouldn't be used

I get stdout when running this and can see the changes, but it doesn't land in the outputs for some reason.

@jaymzh
Copy link
Collaborator

jaymzh commented Feb 9, 2019

The code to get both logs going to the same place is pretty gnarly, and I don't know the windows stuff well enough to debug this... any idea on the fix?

@svmastersamurai
Copy link

@natewalck Have you tried setting windows_subshell to false? The branch of code that writes to console and the log file is not hit unless this value is false:
https://github.com/facebook/chef-utils/blob/master/chefctl/src/chefctl.rb#L1017-L1038

FWIW I was able to see logs in both console and the app created a directory appropriately with this config:

PS> cat $env:temp\chefctl-test\chefctl-config.rb
## THIS FILE IS MANAGED BY CHEF
### LOCAL CHANGES WILL BE OVERRIDDEN
log_dir 'C:\Users\svmastersamurai\AppData\Local\Temp\chefctl-test\outputs'
lock_file "C:/chef/chefctl.lock"
default_chef_options ["--fatal-windows-admin-check"]
chef_client "C:/opscode/chef/bin/chef-client.bat"
lock_time 1800
max_retries 1
windows_subshell false

PS> C:\opscode\chef\embedded\bin\ruby.exe C:\Users\svmastersamurai\github\chef-utils\chefctl\src\chefctl.rb --config $env:temp\chefctl-test\chefctl-config.rb -i

PS> dir $env:temp\chefctl-test\outputs
    Directory: C:\Users\svmastersamurai\AppData\Local\Temp\chefctl-test\outputs
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         6/5/2019   2:45 PM         160361 chef.20190605.1444.1559771097.out
-a---l         6/5/2019   2:44 PM              0 chef.cur.out
-a---l         6/5/2019   2:45 PM              0 chef.last.out

PS> cat $env:temp\chefctl-test\outputs\chef.cur.out -first 10
INFO: Registering FB::CpeinfoReport as a handler for types: report, exception
INFO: Registering FB::TableauReport as a handler for types: report
INFO: Registering FB::ChefRunsReport as a handler for types: report, exception
INFO: Registering FB::FbagentReport as a handler for types: report, exception
INFO: Running on
[2019-06-05T14:45:05-07:00] INFO: *** Chef 14.12.9 ***
[2019-06-05T14:45:05-07:00] INFO: Platform: x64-mingw32
[2019-06-05T14:45:05-07:00] INFO: Chef-client pid: 15864
...

@gleason86
Copy link

This issue can be closed; this issue was caused by plugin_path 'C:/chef/chefctl_hooks.rb' in chefctl-config.rb. More specifically, the function def pre_start was altering Chefctl::Config.path which should be set to nil when windows_subsystem is set to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants