secret
Last active

not_if in powershell resource fails

  • Download Gist
hanging_on_powershell
1 2 3
[Wed, 09 May 2012 07:38:58 +1200] DEBUG: Processing powershell[Creating service TEST_SERVICE from C:\Path\To\MyService.exe] on mybox
[Wed, 09 May 2012 07:38:58 +1200] INFO: Processing powershell[Creating service TEST_SERVICE from C:\Path\To\MyService.exe] action run (c line /chef/cache/cookbooks/on_windows/libraries/service.rb)
[Wed, 09 May 2012 07:38:58 +1200] DEBUG: sh(powershell Get-Service "TEST_SERVICE") - hangs
library_service.rb
Ruby
1 2 3 4 5 6 7 8 9
def create_and_start_service(svc_name,svc_path)
powershell "Creating service #{svc_name} from #{svc_path}" do
code "New-Service -name \"#{svc_name}\" -BinaryPathName \"#{svc_path}\""
not_if "powershell Get-Service \"#{svc_name}\""
end
service svc_name do
action :start
end
end
recipe_foo.rb
Ruby
1
create_and_start_service("TEST_SERVICE","C:\Path\To\MyService.exe")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.