Closed mrswadge closed 1 year ago
Thanks for submitting this @mrswadge. I ran into this the other day and didn't get a chance to submit it. Any chance you can submit that stacktrace?
Hi Tim,
Thanks for coming back so soon. Below you can find the chef-stacktrace.out as found under c:/windows/temp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out
Generated at 2021-11-02 21:05:29 +0000
Errno::EIO: windows_defender[disable windows defender] (packer::remove_defender line 1) had an error: Errno::EIO: windows_service[Windows Defender] (c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource/windows_defender.rb line 126) had an error: Errno::EIO: Input/output error - OpenService: Access is denied.
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/ffi-win32-extensions-1.0.4/lib/ffi/win32/extensions.rb:101:in `raise_windows_error'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/win32-service-2.2.0/lib/win32/service.rb:519:in `configure'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider/service/windows.rb:362:in `set_startup_type'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider/service/windows.rb:173:in `disable_service'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider/service/windows.rb:234:in `block (2 levels) in <class:Windows>'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/mixin/why_run.rb:51:in `add_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:290:in `converge_by'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider/service/windows.rb:233:in `block in <class:Windows>'
(eval):2:in `block in action_disable'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:301:in `instance_eval'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:301:in `compile_and_converge_action'
(eval):2:in `action_disable'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:242:in `run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource.rb:600:in `block in run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource.rb:627:in `with_umask'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource.rb:599:in `run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:74:in `run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:108:in `block in run_all_actions'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:108:in `each'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:108:in `run_all_actions'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection.rb:64:in `insert'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/dsl/declare_resource.rb:267:in `declare_resource'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/dsl/resources.rb:36:in `windows_service'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource/windows_defender.rb:126:in `block in <class:WindowsDefender>'
(eval):2:in `block in action_disable'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:301:in `instance_eval'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:301:in `compile_and_converge_action'
(eval):2:in `action_disable'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/provider.rb:242:in `run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource.rb:600:in `block in run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource.rb:627:in `with_umask'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource.rb:599:in `run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:74:in `run_action'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:108:in `block in run_all_actions'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:108:in `each'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:108:in `run_all_actions'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:132:in `block in converge'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection/resource_list.rb:96:in `block in execute_each_resource'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection/stepable_iterator.rb:54:in `each_with_index'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/resource_collection/resource_list.rb:94:in `execute_each_resource'
c:/opscode/chef/embedded/lib/ruby/3.0.0/forwardable.rb:238:in `execute_each_resource'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/runner.rb:130:in `converge'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/client.rb:686:in `block in converge'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/client.rb:681:in `catch'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/client.rb:681:in `converge'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/client.rb:705:in `converge_and_save'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/client.rb:285:in `run'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/application.rb:305:in `run_with_graceful_exit_option'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/application.rb:281:in `block in run_chef_client'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/local_mode.rb:42:in `with_server_connectivity'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/application.rb:264:in `run_chef_client'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/application/base.rb:352:in `run_application'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/application.rb:67:in `run'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-17.7.29-universal-mingw32/lib/chef/application/solo.rb:60:in `run'
c:/opscode/chef/embedded/lib/ruby/gems/3.0.0/gems/chef-bin-17.7.29/bin/chef-solo:24:in `<top (required)>'
c:/opscode/chef/bin/chef-solo:172:in `load'
c:/opscode/chef/bin/chef-solo:172:in `<main>'
Thanks, Stuart
I'm testing the following PowerShell against Windows 2016 and 2019. I don't know if this would work for other versions of Windows.
powershell_script 'disable windows defender' do
code <<-EOH
Get-WindowsFeature -Name 'Windows-Defender' | %{ if ($_.Installed) { Remove-WindowsFeature $_.Name } }
Get-WindowsFeature -Name 'Windows-Defender-GUI' | %{ if ($_.Installed) { Remove-WindowsFeature $_.Name } }
EOH
end
In the basesetup.ps1 we use this code snippet:
#disable Windows Defender set-mppreference -DisableRealtimeMonitoring $true
Closing this issue due to age. Please feel free to re-open or submit a new issue if the problem still exists with the latest version of the bento code.
Version:
Latest up to commit https://github.com/chef/bento/commit/e5ea77b3ce8b63f461f9f39cbcd03fd8ed4f6334
Environment:
Git-Bash on Windows 10.
Scenario:
Vagrant box image for usage within Virtual Box.
Steps to Reproduce:
Expected Result:
Windows defender to be disabled.
Actual Result: