Puppet Class: lacework::files

Defined in:
manifests/files.pp

Summary

This class is used to control required files for the lacework agent, including config.json

Overview

Parameters:

  • access_token (Any)
  • agent_server_url (Any)
  • config_tags (Any)
  • proxyurl (Any)
  • cmdlinefilter_allow (Any)
  • cmdlinefilter_disallow (Any)
  • fim_filepath (Any)
  • fim_fileignore (Any)
  • fim_noatime (Any)
  • fim_mode (Any)
  • fim_runat (Any)
  • perfmode (Any)
  • cpulimit (Any)
  • memlimit (Any)
  • auto_upgrade (Any)
  • container_engine_endpoint (Any)
  • base_path (Any) (defaults to: '/var/lib/lacework')


4
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'manifests/files.pp', line 4

class lacework::files (
  $access_token,
  $agent_server_url,
  $config_tags,
  $proxyurl,
  $cmdlinefilter_allow,
  $cmdlinefilter_disallow,
  $fim_filepath,
  $fim_fileignore,
  $fim_noatime,
  $fim_mode,
  $fim_runat,
  $perfmode,
  $cpulimit,
  $memlimit,
  $auto_upgrade,
  $container_engine_endpoint,
  $base_path = '/var/lib/lacework',
) {
  if $cmdlinefilter_allow or $cmdlinefilter_disallow {
    $cmdlinefilter = {
      allow    => pick_default($cmdlinefilter_allow, ''),
      disallow => pick_default($cmdlinefilter_disallow, ''),
    }
  } else {
    $cmdlinefilter = undef
  }

  if $fim_filepath or $fim_fileignore or $fim_noatime or $fim_mode or $fim_runat {
    $fim = {
      filepath   => $fim_filepath,
      fileignore => $fim_fileignore,
      mode       => $fim_mode,
      noatime    => String($fim_noatime),
      runat      => $fim_runat,
    }
    $fim_filtered = $fim.filter |$key, $val| { $val =~ NotUndef }
  } else {
    $fim_filtered = undef
  }

  $params = {
    tokens                    => { 'AccessToken' => $access_token },
    serverurl                 => $agent_server_url,
    'AutoUpgrade'             => $auto_upgrade,
    'ContainerEngineEndpoint' => $container_engine_endpoint,
    proxyurl                  => $proxyurl,
    tags                      => $config_tags,
    perfmode                  => $perfmode,
    cmdlinefilter             => $cmdlinefilter,
    fim                       => $fim_filtered,
    cpulimit                  => $cpulimit,
    memlimit                  => $memlimit,
  }
  $params_filtered = $params.filter |$key, $val| { $val =~ NotUndef }

  file { [$base_path, "${base_path}/config"]:
    ensure => 'directory',
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
  }

  file { "${base_path}/config/config.json":
    ensure    => 'file',
    mode      => '0640',
    owner     => 'root',
    group     => 'root',
    content   => to_json_pretty($params_filtered),
    notify    => Service['datacollector'],
    show_diff => false,
  }
}