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
54
55
56
57
58
59
60
61
62
63
64
65 
       | 
      
        # File 'manifests/init.pp', line 14
class fluentbit(
  # module configs
  Boolean $manage_package_repo = true,
  Boolean $create_defaults     = false,
  String $service_name         = 'td-agent-bit',
  ### START Hiera Lookups ###
  Hash $input_plugins          = $create_defaults ? {
    true => { 'syslog' => { mode => unix_udp, }},
    false => {}
    },
  Hash $output_plugins         = $create_defaults ? {
    true => { 'es' => {}},
    false => {}
    },
  Hash $filters                = $create_defaults ? {
    true => { 'modify' => {}},
    false => {}
    },
  ) {
  # configures repo if enabled
  if $manage_package_repo {
    class{'fluentbit::repo':
      before => Class['fluentbit::install']
    }
  }
  # install package and configure td-agent-bit with service
  class{'fluentbit::install': }
    -> class{'fluentbit::config': }
    -> class{'fluentbit::service': }
  contain fluentbit::install
  contain fluentbit::service
  # use create resources to define resources
  # input plugins
  $input_plugins.each | String $plugin, Hash $attributes | {
    Resource["fluentbit::input::${plugin}"] {
      $plugin: * => $attributes;
    }
  }
  # output plugins
  $output_plugins.each | String $plugin, Hash $attributes | {
    Resource["fluentbit::output::${plugin}"] {
      $plugin: * => $attributes;
    }
  }
  # filter plugins
  $filters.each | String $plugin, Hash $attributes | {
    Resource["fluentbit::filter::${plugin}"] {
      $plugin: * => $attributes;
    }
  }
}
       |