Class: Chef::Resource::Service
- Inherits:
-
Chef::Resource
- Object
- Chef::Resource
- Chef::Resource::Service
- Defined in:
- lib/chef/resource/service.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Chef::Resource
Instance Attribute Summary
Attributes inherited from Chef::Resource
#allowed_actions, #cookbook_name, #declared_type, #default_guard_interpreter, #elapsed_time, #enclosing_provider, #logger, #params, #recipe_name, #resource_initializing, #run_context, #source_line, #updated
Instance Method Summary collapse
-
#enabled(arg = nil) ⇒ Object
if the service is enabled or not.
-
#init_command(arg = nil) ⇒ Object
The path to the init script associated with the service.
-
#initialize(name, run_context = nil) ⇒ Service
constructor
A new instance of Service.
-
#masked(arg = nil) ⇒ Object
if the service is masked or not.
- #options(arg = nil) ⇒ Object
- #parameters(arg = nil) ⇒ Object
-
#pattern(arg = nil) ⇒ Object
regex for match against ps -ef when !supports && status == nil.
-
#priority(arg = nil) ⇒ Object
Priority arguments can have two forms:.
- #reload_command(arg = nil) ⇒ Object
-
#restart_command(arg = nil) ⇒ Object
command to call to restart service.
- #run_levels(arg = nil) ⇒ Object
-
#running(arg = nil) ⇒ Object
if the service is running or not.
- #service_name(arg = nil) ⇒ Object
-
#start_command(arg = nil) ⇒ Object
command to call to start service.
-
#status_command(arg = nil) ⇒ Object
command to call to get status of service.
-
#stop_command(arg = nil) ⇒ Object
command to call to stop service.
-
#timeout(arg = nil) ⇒ Object
timeout only applies to the windows service manager.
- #user(arg = nil) ⇒ Object
Methods inherited from Chef::Resource
action, #action, #action=, action_class, #after_created, allowed_actions, allowed_actions=, #as_json, #before_notifications, #cookbook_version, #current_value, #current_value_does_not_exist!, #custom_exception_message, custom_resource?, #customize_exception, declare_action_class, #declared_key, default_action, default_action=, #defined_at, #delayed_action, #delayed_notifications, deprecated, description, #events, examples, from_hash, from_json, #guard_interpreter, #identity, identity_attr, identity_property, #ignore_failure, #immediate_notifications, inherited, #inspect, introduced, is_custom_resource!, json_create, load_current_value, #load_from, #lookup_provider_constant, #method_missing, #name, #node, #not_if, #notifies, #notifies_before, #notifies_delayed, #notifies_immediately, #only_if, #provider, #provider=, #provider_for_action, provides, provides?, remove_canonical_dsl, #resolve_notification_references, resource_for_node, resource_matching_short_name, #resource_name, resource_name, resource_name=, #resources, #retries, #retry_delay, #run_action, #sensitive, #should_skip?, sorted_descendants, #source_line_file, #source_line_number, state_attrs, #state_for_resource_reporter, #subscribes, #to_hash, #to_json, #to_s, #to_text, #updated?, #updated_by_last_action, #updated_by_last_action?, use_automatic_resource_name, #validate_action, #validate_resource_spec!, #value_to_text
Methods included from Mixin::Provides
#provided_as, #provides, #provides?
Methods included from Mixin::DescendantsTracker
#descendants, descendants, direct_descendants, #direct_descendants, find_descendants_by_name, #find_descendants_by_name, #inherited, store_inherited
Methods included from Mixin::ConvertToClassName
#constantize, #convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #normalize_snake_case_name, #snake_case_basename
Methods included from Mixin::Deprecation
#deprecated_attr, #deprecated_attr_reader, #deprecated_attr_writer, #deprecated_ivar
Methods included from Mixin::Properties
included, #property_description, #property_is_set?, #reset_property
Methods included from Mixin::ParamsValidate
#lazy, #set_or_return, #validate
Methods included from Mixin::ShellOut
#a_to_s, #clean_array, #shell_out, #shell_out!, #shell_out_compact, #shell_out_compact!, #shell_out_compact_timeout, #shell_out_compact_timeout!, #shell_out_with_systems_locale, #shell_out_with_systems_locale!
Methods included from Mixin::PathSanity
#enforce_path_sanity, #sanitized_path
Methods included from Mixin::PowershellOut
#powershell_out, #powershell_out!
Methods included from Mixin::WindowsArchitectureHelper
#assert_valid_windows_architecture!, #disable_wow64_file_redirection, #forced_32bit_override_required?, #is_i386_process_on_x86_64_windows?, #node_supports_windows_architecture?, #node_windows_architecture, #restore_wow64_file_redirection, #valid_windows_architecture?, #with_os_architecture, #wow64_architecture_override_required?, #wow64_directory
Methods included from Mixin::PowershellExec
Methods included from DSL::PlatformIntrospection
#docker?, #platform?, #platform_family?, #value_for_platform, #value_for_platform_family
Methods included from DSL::RebootPending
Methods included from DSL::RegistryHelper
#registry_data_exists?, #registry_get_subkeys, #registry_get_values, #registry_has_subkeys?, #registry_key_exists?, #registry_value_exists?
Methods included from DSL::DataQuery
#data_bag, #data_bag_item, #search
Methods included from EncryptedDataBagItem::CheckEncrypted
Constructor Details
#initialize(name, run_context = nil) ⇒ Service
Returns a new instance of Service.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/chef/resource/service.rb', line 40 def initialize(name, run_context = nil) super @service_name = name @enabled = nil @running = nil @masked = nil @options = nil @parameters = nil @pattern = service_name @start_command = nil @stop_command = nil @status_command = nil @restart_command = nil @reload_command = nil @init_command = nil @priority = nil @timeout = nil @run_levels = nil @user = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Resource
Instance Method Details
#enabled(arg = nil) ⇒ Object
if the service is enabled or not
136 137 138 139 140 141 142 |
# File 'lib/chef/resource/service.rb', line 136 def enabled(arg = nil) set_or_return( :enabled, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#init_command(arg = nil) ⇒ Object
The path to the init script associated with the service. On many distributions this is ‘/etc/init.d/SERVICE_NAME’ by default. In non-standard configurations setting this value will save having to specify overrides for the start_command, stop_command and restart_command attributes.
127 128 129 130 131 132 133 |
# File 'lib/chef/resource/service.rb', line 127 def init_command(arg = nil) set_or_return( :init_command, arg, :kind_of => [ String ] ) end |
#masked(arg = nil) ⇒ Object
if the service is masked or not
154 155 156 157 158 159 160 |
# File 'lib/chef/resource/service.rb', line 154 def masked(arg = nil) set_or_return( :masked, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#options(arg = nil) ⇒ Object
162 163 164 165 166 167 168 |
# File 'lib/chef/resource/service.rb', line 162 def (arg = nil) set_or_return( :options, arg.respond_to?(:split) ? arg.shellsplit : arg, :kind_of => [ Array, String ] ) end |
#parameters(arg = nil) ⇒ Object
197 198 199 200 201 202 203 |
# File 'lib/chef/resource/service.rb', line 197 def parameters(arg = nil) set_or_return( :parameters, arg, :kind_of => [ Hash ] ) end |
#pattern(arg = nil) ⇒ Object
regex for match against ps -ef when !supports && status == nil
70 71 72 73 74 75 76 |
# File 'lib/chef/resource/service.rb', line 70 def pattern(arg = nil) set_or_return( :pattern, arg, :kind_of => [ String ] ) end |
#priority(arg = nil) ⇒ Object
Priority arguments can have two forms:
-
a simple number, in which the default start runlevels get that as the start value and stop runlevels get 100 - value.
-
a hash like { 2 => [:start, 20], 3 => [:stop, 55] }, where the service will be marked as started with priority 20 in runlevel 2, stopped in 3 with priority 55 and no symlinks or similar for other runlevels
180 181 182 183 184 185 186 |
# File 'lib/chef/resource/service.rb', line 180 def priority(arg = nil) set_or_return( :priority, arg, :kind_of => [ Integer, String, Hash ] ) end |
#reload_command(arg = nil) ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/chef/resource/service.rb', line 114 def reload_command(arg = nil) set_or_return( :reload_command, arg, :kind_of => [ String, NilClass, FalseClass ] ) end |
#restart_command(arg = nil) ⇒ Object
command to call to restart service
106 107 108 109 110 111 112 |
# File 'lib/chef/resource/service.rb', line 106 def restart_command(arg = nil) set_or_return( :restart_command, arg, :kind_of => [ String, NilClass, FalseClass ] ) end |
#run_levels(arg = nil) ⇒ Object
205 206 207 208 209 210 |
# File 'lib/chef/resource/service.rb', line 205 def run_levels(arg = nil) set_or_return( :run_levels, arg, :kind_of => [ Array ] ) end |
#running(arg = nil) ⇒ Object
if the service is running or not
145 146 147 148 149 150 151 |
# File 'lib/chef/resource/service.rb', line 145 def running(arg = nil) set_or_return( :running, arg, :kind_of => [ TrueClass, FalseClass ] ) end |
#service_name(arg = nil) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/chef/resource/service.rb', line 61 def service_name(arg = nil) set_or_return( :service_name, arg, :kind_of => [ String ] ) end |
#start_command(arg = nil) ⇒ Object
command to call to start service
79 80 81 82 83 84 85 |
# File 'lib/chef/resource/service.rb', line 79 def start_command(arg = nil) set_or_return( :start_command, arg, :kind_of => [ String, NilClass, FalseClass ] ) end |
#status_command(arg = nil) ⇒ Object
command to call to get status of service
97 98 99 100 101 102 103 |
# File 'lib/chef/resource/service.rb', line 97 def status_command(arg = nil) set_or_return( :status_command, arg, :kind_of => [ String, NilClass, FalseClass ] ) end |
#stop_command(arg = nil) ⇒ Object
command to call to stop service
88 89 90 91 92 93 94 |
# File 'lib/chef/resource/service.rb', line 88 def stop_command(arg = nil) set_or_return( :stop_command, arg, :kind_of => [ String, NilClass, FalseClass ] ) end |
#timeout(arg = nil) ⇒ Object
timeout only applies to the windows service manager
189 190 191 192 193 194 195 |
# File 'lib/chef/resource/service.rb', line 189 def timeout(arg = nil) set_or_return( :timeout, arg, :kind_of => Integer ) end |
#user(arg = nil) ⇒ Object
212 213 214 215 216 217 218 |
# File 'lib/chef/resource/service.rb', line 212 def user(arg = nil) set_or_return( :user, arg, :kind_of => [ String ] ) end |