Class: Chef::Provider::SystemdUnit
- Inherits:
-
Chef::Provider
- Object
- Chef::Provider
- Chef::Provider::SystemdUnit
- Includes:
- Mixin::ShellOut, Mixin::Which
- Defined in:
- lib/chef/provider/systemd_unit.rb
Instance Attribute Summary
Attributes inherited from Chef::Provider
#action, #after_resource, #current_resource, #logger, #new_resource, #recipe_name, #run_context
Instance Method Summary collapse
- #active? ⇒ Boolean
- #define_resource_requirements ⇒ Object
- #enabled? ⇒ Boolean
- #indirect? ⇒ Boolean
- #load_current_resource ⇒ Object
- #masked? ⇒ Boolean
- #static? ⇒ Boolean
Methods included from Mixin::ShellOut
apply_default_env, maybe_add_timeout, #shell_out, #shell_out!
Methods inherited from Chef::Provider
action, #action_nothing, #check_resource_semantics!, #cleanup_after_converge, #compile_and_converge_action, #converge_by, #converge_if_changed, #cookbook_name, #description, #events, include_resource_dsl?, include_resource_dsl_module, #initialize, #introduced, #load_after_resource, #node, #process_resource_requirements, provides, provides?, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, supports?, use, use_inline_resources, #validate_required_properties!, #whyrun_mode?, #whyrun_supported?
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::LazyModuleInclude
#descendants, #include, #included
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
#powershell_exec, #powershell_exec!
Methods included from DSL::Powershell
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::ChefVault
#chef_vault, #chef_vault_item, #chef_vault_item_for_environment
Methods included from DSL::DataQuery
#data_bag, #data_bag_item, #search, #tagged?
Methods included from EncryptedDataBagItem::CheckEncrypted
Methods included from DSL::PlatformIntrospection
#older_than_win_2012_or_8?, #platform?, #platform_family?, #value_for_platform, #value_for_platform_family
Methods included from DSL::Recipe
#exec, #have_resource_class_for?, #resource_class_for
Methods included from DSL::Definitions
add_definition, #evaluate_resource_definition, #has_resource_definition?
Methods included from DSL::Resources
add_resource_dsl, remove_resource_dsl
Methods included from DSL::Cheffish
Methods included from DSL::RebootPending
Methods included from DSL::IncludeRecipe
Methods included from Mixin::NotifyingBlock
#notifying_block, #subcontext_block
Methods included from DSL::DeclareResource
#build_resource, #declare_resource, #delete_resource, #delete_resource!, #edit_resource, #edit_resource!, #find_resource, #find_resource!, #resources, #with_run_context
Constructor Details
This class inherits a constructor from Chef::Provider
Instance Method Details
#active? ⇒ Boolean
205 206 207 |
# File 'lib/chef/provider/systemd_unit.rb', line 205 def active? systemctl_execute("is-active", new_resource.unit_name).exitstatus == 0 end |
#define_resource_requirements ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/chef/provider/systemd_unit.rb', line 51 def define_resource_requirements super requirements.assert(:create) do |a| a.assertion { IniParse.parse(new_resource.to_ini) } a. "Unit content is not valid INI text" end end |
#enabled? ⇒ Boolean
209 210 211 |
# File 'lib/chef/provider/systemd_unit.rb', line 209 def enabled? systemctl_execute("is-enabled", new_resource.unit_name).exitstatus == 0 end |
#indirect? ⇒ Boolean
221 222 223 |
# File 'lib/chef/provider/systemd_unit.rb', line 221 def indirect? systemctl_execute("is-enabled", new_resource.unit_name).stdout.include?("indirect") end |
#load_current_resource ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chef/provider/systemd_unit.rb', line 35 def load_current_resource @current_resource = Chef::Resource::SystemdUnit.new(new_resource.name) current_resource.unit_name(new_resource.unit_name) current_resource.content(::File.read(unit_path)) if ::File.exist?(unit_path) current_resource.user(new_resource.user) current_resource.enabled(enabled?) current_resource.active(active?) current_resource.masked(masked?) current_resource.static(static?) current_resource.indirect(indirect?) current_resource.triggers_reload(new_resource.triggers_reload) current_resource end |
#masked? ⇒ Boolean
213 214 215 |
# File 'lib/chef/provider/systemd_unit.rb', line 213 def masked? systemctl_execute("status", new_resource.unit_name).stdout.include?("masked") end |
#static? ⇒ Boolean
217 218 219 |
# File 'lib/chef/provider/systemd_unit.rb', line 217 def static? systemctl_execute("is-enabled", new_resource.unit_name).stdout.include?("static") end |