Module: PuppetX::Puppetlabs::Splunk::Type

Defined in:
lib/puppet_x/puppetlabs/splunk/type.rb

Class Method Summary collapse

Class Method Details

.clone_type(type) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puppet_x/puppetlabs/splunk/type.rb', line 5

def self.clone_type(type)
  type.ensurable

  type.define_singleton_method(:title_patterns) do
    [
      [%r{^([^\/]*)$}, [[:section]]],   # matches section titles without slashes, like 'tcpout:indexers'
      [%r{^(.*\/\/.*)\/(.*)$},          # matches section titles containing '//' and a setting,
       [                                # like: 'monitor:///var/log/messages/index'
         [:section],       # where 'monitor:///var/log/messages' is the section
         [:setting]        # and 'index' is the setting.
       ]],
      [%r{^(.*\/\/.*)$}, [[:section]]], # matches section titles containing '//', like 'tcp://127.0.0.1:19500'
      [%r{^(.*)\/(.*)$},                # matches plain 'section/setting' titles, like: 'tcpout:indexers/server'
       [
         [:section],
         [:setting]
       ]]
    ]
  end
  type.newproperty(:value) do
    desc 'The value of the setting to be defined.'
    munge do |v|
      v.to_s.strip
    end
  end
  type.newparam(:setting) do
    desc 'The setting being defined.'
    isnamevar
    munge do |v|
      v.to_s.strip
    end
  end
  type.newparam(:section) do
    desc 'The section the setting is defined under.'
    isnamevar
    munge do |v|
      v.to_s.strip
    end
  end
  type.newparam(:context) do
    desc 'The context in which to define the setting.'
    isnamevar
    munge do |v|
      v.to_s.strip
    end
    defaultto('system/local')
  end
  type.newparam(:name)
end