diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-10-28 15:12:27 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-10-28 15:12:27 -0700 |
commit | 3c02cc2b86d3d8a2f573b863a2186ef24198fbe4 (patch) | |
tree | 291da5be4ad986f0a66acb6b7078a264552e0aea | |
parent | 79772c0ca81d6c7481f74aa07ae5a5873698cf24 (diff) | |
download | chef-3c02cc2b86d3d8a2f573b863a2186ef24198fbe4.tar.gz |
Add examples to windows_service and correct some formatting
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/windows_service.rb | 108 | ||||
-rw-r--r-- | lib/chef/resource/windows_task.rb | 3 |
2 files changed, 110 insertions, 1 deletions
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb index 0fa007497b..5920f61011 100644 --- a/lib/chef/resource/windows_service.rb +++ b/lib/chef/resource/windows_service.rb @@ -39,6 +39,114 @@ class Chef description "Use the **windows_service** resource to create, delete, or manage a service on the Microsoft Windows platform." introduced "12.0" + examples <<~DOC + **Starting Services** + + Start a service with a `manual` startup type: + + ```ruby + windows_service 'BITS' do + action :configure_startup + startup_type :manual + end + ``` + + **Creating Services** + + Create a service named chef-client: + + ```ruby + windows_service 'chef-client' do + action :create + binary_path_name "C:\\opscode\\chef\\bin" + end + ``` + + Create a service with `service_name` and `display_name`: + + ```ruby + windows_service 'Setup chef-client as a service' do + action :create + display_name 'CHEF-CLIENT' + service_name 'chef-client' + binary_path_name "C:\\opscode\\chef\\bin" + end + ``` + + Create a service with the `manual` startup type: + + ```ruby + windows_service 'chef-client' do + action :create + binary_path_name "C:\\opscode\\chef\\bin" + startup_type :manual + end + ``` + + Create a service with the `disabled` startup type: + + ```ruby + windows_service 'chef-client' do + action :create + binary_path_name "C:\\opscode\\chef\\bin" + startup_type :disabled + end + ``` + + Create a service with the `automatic` startup type and delayed start enabled: + + ```ruby + windows_service 'chef-client' do + action :create + binary_path_name "C:\\opscode\\chef\\bin" + startup_type :automatic + delayed_start true + end + ``` + + Create a service with a description: + + ```ruby + windows_service 'chef-client' do + action :create + binary_path_name "C:\\opscode\\chef\\bin" + startup_type :automatic + description "Chef client as service" + end + ``` + + **Deleting Services** + + Delete a service named chef-client: + + ```ruby + windows_service 'chef-client' do + action :delete + end + ``` + + Delete a service with the `service_name` property: + + ```ruby + windows_service 'Delete chef client' do + action :delete + service_name 'chef-client' + end + ``` + + **Configuring Services** + + Change an existing service from automatic to manual startup: + + ```ruby + windows_service 'chef-client' do + action :configure + binary_path_name "C:\\opscode\\chef\\bin" + startup_type :manual + end + ``` + DOC + allowed_actions :configure_startup, :create, :delete, :configure diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index cc2c80d4c6..ffbeee7ea3 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -75,7 +75,7 @@ class Chef command 'chef-client' run_level :highest frequency :once - start_time "16:10" + start_time 16:10' end ``` @@ -115,6 +115,7 @@ class Chef ``` **Create a scheduled task to run when computer is idle with idle duration 20 min**: + ```ruby windows_task 'chef-client' do command 'chef-client' |