diff options
Diffstat (limited to 'lib/chef/resource/windows_service.rb')
-rw-r--r-- | lib/chef/resource/windows_service.rb | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb index 9d61990605..51d016a4f2 100644 --- a/lib/chef/resource/windows_service.rb +++ b/lib/chef/resource/windows_service.rb @@ -41,41 +41,47 @@ class Chef allowed_actions :configure_startup, :create, :delete, :configure - # The display name to be used by user interface programs to identify the - # service. This string has a maximum length of 256 characters. property :display_name, String, regex: /^.{1,256}$/, - validation_message: "The display_name can only be a maximum of 256 characters!", - introduced: "14.0" + description: "The display name to be used by user interface programs to identify the service. This string has a maximum length of 256 characters.", + validation_message: "The display_name can only be a maximum of 256 characters!", + introduced: "14.0" # https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L19-L29 - property :desired_access, Integer, default: SERVICE_ALL_ACCESS + property :desired_access, Integer, + default: SERVICE_ALL_ACCESS, + introduced: "14.0" # https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L31-L41 - property :service_type, Integer, default: SERVICE_WIN32_OWN_PROCESS + property :service_type, Integer, default: SERVICE_WIN32_OWN_PROCESS, + introduced: "14.0" # Valid options: # - :automatic # - :manual # - :disabled # Reference: https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L49-L54 - property :startup_type, [Symbol], equal_to: %i{automatic manual disabled}, default: :automatic, coerce: proc { |x| - if x.is_a?(Integer) - ALLOWED_START_TYPES.invert.fetch(x) do - Chef::Log.warn("Unsupported startup_type #{x}, falling back to :automatic") - :automatic + property :startup_type, [Symbol], + equal_to: %i{automatic manual disabled}, + default: :automatic, + description: "Use to specify the startup type of the service.", + coerce: proc { |x| + if x.is_a?(Integer) + ALLOWED_START_TYPES.invert.fetch(x) do + Chef::Log.warn("Unsupported startup_type #{x}, falling back to :automatic") + :automatic + end + elsif x.is_a?(String) + x.to_sym + else + x end - elsif x.is_a?(String) - x.to_sym - else - x - end - } - - # This only applies if startup_type is :automatic + } + # 1 == delayed start is enabled # 0 == NO delayed start property :delayed_start, [TrueClass, FalseClass], introduced: "14.0", + description: "Set the startup type to delayed start. This only applies if `startup_type` is `:automatic`", default: false, coerce: proc { |x| if x.is_a?(Integer) x == 0 ? false : true @@ -85,31 +91,34 @@ class Chef } # https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L43-L47 - property :error_control, Integer, default: SERVICE_ERROR_NORMAL + property :error_control, Integer, + default: SERVICE_ERROR_NORMAL, + introduced: "14.0" property :binary_path_name, String, introduced: "14.0", - description: "The fully qualified path to the service binary file. The path can also include arguments for an auto-start service. This is required for ':create' and ':configure' actions" + description: "The fully qualified path to the service binary file. The path can also include arguments for an auto-start service. This is required for `:create` and `:configure` actions" property :load_order_group, String, introduced: "14.0", - description: "The names of the load ordering group of which this service is a member. Don't set this property if the service does not belong to a group." - - # A pointer to a double null-terminated array of null-separated names of - # services or load ordering groups that the system must start before this - # service. Specify nil or an empty string if the service has no - # dependencies. Dependency on a group means that this service can run if - # at least one member of the group is running after an attempt to start - # all members of the group. + description: "The name of the service's load ordering group(s)." + property :dependencies, [String, Array], + description: "A pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service. Specify `nil` or an empty string if the service has no dependencies. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.", introduced: "14.0" property :description, String, description: "Description of the service.", introduced: "14.0" - property :run_as_user, String, default: "localsystem", coerce: proc { |x| x.downcase } - property :run_as_password, String, default: "" + property :run_as_user, String, + description: "The user under which a Microsoft Windows service runs.", + default: "localsystem", + coerce: proc { |x| x.downcase } + + property :run_as_password, String, + description: "The password for the user specified by `run_as_user`.", + default: "" end end end |