Class: Puppet::Util::RunMode

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/run_mode.rb

Direct Known Subclasses

UnixRunMode, WindowsRunMode

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ RunMode

Returns a new instance of RunMode.



8
9
10
# File 'lib/puppet/util/run_mode.rb', line 8

def initialize(name)
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/puppet/util/run_mode.rb', line 12

def name
  @name
end

Class Method Details

.[](name) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/puppet/util/run_mode.rb', line 14

def self.[](name)
  @run_modes ||= {}
  if Puppet::Util::Platform.windows?
    @run_modes[name] ||= WindowsRunMode.new(name)
  else
    @run_modes[name] ||= UnixRunMode.new(name)
  end
end

Instance Method Details

#agent?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/puppet/util/run_mode.rb', line 31

def agent?
  name == :agent
end

#log_dirObject



43
44
45
# File 'lib/puppet/util/run_mode.rb', line 43

def log_dir
  RunMode[name].log_dir
end

#master?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/puppet/util/run_mode.rb', line 27

def master?
  name == :master || name == :server
end

#run_dirObject



39
40
41
# File 'lib/puppet/util/run_mode.rb', line 39

def run_dir
  RunMode[name].run_dir
end

#server?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/puppet/util/run_mode.rb', line 23

def server?
  name == :master || name == :server
end

#user?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/puppet/util/run_mode.rb', line 35

def user?
  name == :user
end