Class: ChefInstance::Resource::Instance

Inherits:
Chef::Resource
  • Object
show all
Defined in:
lib/chef_instance/resource_instance.rb

Overview

Provides a Superclass Chef Resource to help with Factories.

Instance Method Summary collapse

Constructor Details

#initialize(new_resource, run_context = nil) ⇒ Instance

Construct a new ChefInstance::Resource::Instance.

Parameters:

  • new_resource (Chef::Resource)
  • run_context (Chef::RunContext) (defaults to: nil)


10
11
12
13
14
15
# File 'lib/chef_instance/resource_instance.rb', line 10

def initialize(new_resource, run_context = nil)
  super
  @provider = ChefInstance::Provider::Instance
  @action = :create
  @allowed_actions = [:create, :destroy, :enable, :disable, :nothing]
end

Instance Method Details

#install_options(arg = nil) ⇒ Object

A hash passed to the install type. Used to pass end-user overrides to the installer.

Parameters:

  • arg (Hash) (defaults to: nil)


20
21
22
# File 'lib/chef_instance/resource_instance.rb', line 20

def install_options(arg = nil)
  set_or_return(:install_options, arg, kind_of: Hash)
end

#install_type(arg = nil) ⇒ Object

The type of installation you are doing.

Parameters:

  • arg (Symbol) (defaults to: nil)


26
27
28
29
30
31
32
# File 'lib/chef_instance/resource_instance.rb', line 26

def install_type(arg = nil)
  set_or_return(:install_type,
                arg,
                kind_of: [Symbol],
                required: true,
                equal_to: [:package, :existing])
end

#namespace(arg = nil) ⇒ Object

Provide the namespace for lookups. Because the provider subclasses Chef::Provider Its self.class points us in the wrong direction.

Parameters:

  • arg (String) (defaults to: nil)

    namespace to use for lookups.



55
56
57
58
59
60
# File 'lib/chef_instance/resource_instance.rb', line 55

def namespace(arg = nil)
  set_or_return(:namespace,
                arg,
                kind_of: String,
                default: 'ChefInstance')
end

#service_options(arg = nil) ⇒ Object

A hash passed to the service type. Used to pass end-user overrides to the service.

Parameters:

  • arg (Hash) (defaults to: nil)


37
38
39
# File 'lib/chef_instance/resource_instance.rb', line 37

def service_options(arg = nil)
  set_or_return(:service_options, arg, kind_of: Hash)
end

#service_type(arg = nil) ⇒ Object

The type of service manager you are using.

Parameters:

  • arg (Symbol) (defaults to: nil)


43
44
45
46
47
48
49
# File 'lib/chef_instance/resource_instance.rb', line 43

def service_type(arg = nil)
  set_or_return(:service_type,
                arg,
                kind_of: Symbol,
                required: true,
                equal_to: [:init, :runit])
end