OLD | NEW |
1 # == Class: adblockplus::log | 1 # == Class: adblockplus::log |
2 # | 2 # |
3 # Default root namespace for integrating custom logging entities. | 3 # Default root namespace for integrating custom logging entities. |
4 # | 4 # |
5 # === Parameters: | 5 # === Parameters: |
6 # | 6 # |
7 # [*ensure*] | |
8 # Whether associated resources are ment to be 'present' or 'absent'. | |
9 # | |
10 # [*name*] | |
11 # Used as label to connect adblockplus::log::tracker instances to class | |
12 # adblockplus::log::forwarder, defaults to 'adblockplus::log'. | |
13 # | |
14 # [*rotations*] | 7 # [*rotations*] |
15 # A hash of adblockplus::log::rotation $name => $parameter items | 8 # A hash of adblockplus::log::rotation $name => $parameter items |
16 # to set up in this context, i.e. via Hiera. | 9 # to set up in this context, i.e. via Hiera. |
17 # | 10 # |
18 # [*trackers*] | |
19 # A hash of adblockplus::log::rotation $title => $parameter items | |
20 # to set up in this context, i.e. via Hiera. | |
21 # | |
22 # === Examples: | 11 # === Examples: |
23 # | 12 # |
24 # class {'adblockplus::log': | 13 # class {'adblockplus::log': |
25 # rotations => { | 14 # rotations => { |
26 # # see adblockplus::log::rotation | 15 # # see adblockplus::log::rotation |
27 # }, | 16 # }, |
28 # trackers => { | |
29 # # see adblockplus::log::tracker | |
30 # }, | |
31 # } | 17 # } |
32 # | 18 # |
33 class adblockplus::log ( | 19 class adblockplus::log ( |
34 $ensure = 'present', | |
35 $rotations = hiera('adblockplus::log::rotations', {}), | 20 $rotations = hiera('adblockplus::log::rotations', {}), |
36 $trackers = hiera('adblockplus::log::trackers', {}), | |
37 ) { | 21 ) { |
38 | 22 |
39 include adblockplus | 23 include adblockplus |
40 include stdlib | 24 realize(File[$adblockplus::directory]) |
41 | 25 |
42 # Used as internal constants within adblockplus::log::* resources | 26 # Used as internal constants within adblockplus::log::* resources |
43 $directory = "$adblockplus::directory/log/data" | 27 $directory = "$adblockplus::directory/log" |
| 28 $group = 'log' |
44 $user = 'log' | 29 $user = 'log' |
45 | 30 |
46 # Required on both log generating and log processing hosts | |
47 class {'fluent': | |
48 package => { | |
49 ensure => $ensure ? { | |
50 'present' => '2.3.1-0', | |
51 default => 'absent', | |
52 }, | |
53 provider => 'apt', | |
54 }, | |
55 user => { | |
56 groups => ['adm'], | |
57 shell => '/bin/sh', | |
58 }, | |
59 } | |
60 | |
61 # Used as internal shortcuts within adblockplus::log::* resources | |
62 $agent = getparam(Package['fluent'], 'name') | |
63 $index = sprintf('/var/run/%s/index.csv', $agent) | |
64 $group = getparam(User['fluent'], 'gid') | |
65 | |
66 fluent::config {$title: | |
67 content => template('adblockplus/log/fluentd/default.conf.erb'), | |
68 ensure => $ensure, | |
69 name => '90-adblockplus-log-defaults', | |
70 } | |
71 | |
72 # Invoke realize(File[$adblockplus::log::directory]) when neccessary | 31 # Invoke realize(File[$adblockplus::log::directory]) when neccessary |
73 @file {$directory: | 32 @file {$directory: |
74 before => Service['fluent'], | |
75 ensure => 'directory', | 33 ensure => 'directory', |
76 group => $group, | 34 require => File[$adblockplus::directory], |
77 mode => 0775, | |
78 owner => $user, | |
79 } | 35 } |
80 | 36 |
81 # Invoke realize(User[$adblockplus::log::user]) when necessary | 37 # Invoke realize(User[$adblockplus::log::user]) when necessary |
82 @user {$user: | 38 @user {$user: |
83 before => File[$directory], | 39 ensure => 'present', |
84 ensure => $ensure, | |
85 groups => [$group], | |
86 home => "$adblockplus::directory/log", | |
87 managehome => true, | 40 managehome => true, |
88 require => [ | |
89 File[$adblockplus::directory], | |
90 User['fluent'], | |
91 ], | |
92 } | 41 } |
93 | 42 |
94 # See modules/adblockplus/manifests/log/rotation.pp | 43 # See modules/adblockplus/manifests/log/rotation.pp |
95 create_resources('adblockplus::log::rotation', $rotations) | 44 create_resources('adblockplus::log::rotation', $rotations) |
96 | |
97 # See modules/adblockplus/manifests/log/tracker.pp | |
98 create_resources('adblockplus::log::tracker', $trackers) | |
99 } | 45 } |
OLD | NEW |