OLD | NEW |
1 # == Class: adblockplus::log::master | 1 # == Class: adblockplus::log::master |
2 # | 2 # |
3 # A server setup to collect and pre-process (i.e. anonymize and combine) | 3 # A server setup to collect and pre-process log files. This is still a stub, |
4 # log files using Logstash (https://logstash.net/) pipelines. | 4 # the generated configuration corresponds to recent package defaults. |
5 # | 5 # |
6 # === Parameters: | 6 # === Parameters: |
7 # | 7 # |
8 # [*uplinks*] | 8 # [*ensure*] |
9 # A hash of $name => $parameters resembling the servers registry within | 9 # Whether the master setup should be 'present' or 'absent', defaults |
10 # file modules/private/hiera/hosts.yaml, which is used by default. | 10 # to $adblockplus::log::ensure. |
11 # | 11 # |
12 # === Examples: | 12 # === Examples: |
13 # | 13 # |
14 # class {'adblockplus::log::master': | 14 # class {'adblockplus::log::master': |
15 # uplinks => { | |
16 # 'filter1' => { | |
17 # ip => '10.8.0.1', | |
18 # ssh_public_key 'AAA...', | |
19 # }, | |
20 # }, | |
21 # } | 15 # } |
22 # | 16 # |
23 class adblockplus::log::master ( | 17 class adblockplus::log::master ( |
24 $uplinks = hiera('adblockplus::log::master::uplinks', hiera('servers', {})), | 18 $ensure = undef, |
25 ) { | 19 ) { |
26 | 20 |
27 include adblockplus::log | 21 include adblockplus::log |
| 22 include adblockplus::log::processor |
| 23 include stdlib |
| 24 |
| 25 # Virtual resource from modules/adblockplus/manifests/init.pp |
| 26 realize(File[$adblockplus::directory]) |
| 27 |
| 28 # Virtual resource from modules/adblockplus/manifests/log.pp |
28 realize(File[$adblockplus::log::directory]) | 29 realize(File[$adblockplus::log::directory]) |
29 realize(User[$adblockplus::log::user]) | 30 realize(User[$adblockplus::log::user]) |
30 | 31 |
31 # Used as internal constants within adblockplus::log::* resources | 32 # See modules/fluent/manifests/config.pp |
32 $data_directory = "$adblockplus::log::directory/data" | 33 fluent::config {$title: |
33 $uplink_directory = "$adblockplus::log::directory/uplink" | 34 content => template('adblockplus/log/fluentd/master.conf.erb'), |
34 $import_script = '/usr/local/bin/adblockplus-log-import' | 35 ensure => pick($ensure, $adblockplus::log::ensure), |
35 | 36 name => '50-adblockplus-log-master', |
36 # Mapping hiera values explicitly becomes obsolete with Puppet 3.x | |
37 class {'logstash': | |
38 contrib => hiera('logstash::contrib', false), | |
39 ensure => hiera('logstash::ensure', 'running'), | |
40 pipelines => hiera('logstash::pipelines', {}), | |
41 version => hiera('logstash::version', '1.4'), | |
42 } | 37 } |
43 | |
44 # Location for input sockets in Logstash pipeline configurations | |
45 file {$uplink_directory: | |
46 ensure => 'directory', | |
47 group => $adblockplus::log::group, | |
48 mode => 0750, | |
49 owner => 'logstash', | |
50 require => [ | |
51 File[$adblockplus::log::directory], | |
52 Package['logstash'], | |
53 User[$adblockplus::log::user], | |
54 ], | |
55 } | |
56 | |
57 # Default location for output files in Logstash pipeline configurations | |
58 file {$data_directory: | |
59 ensure => 'directory', | |
60 before => Service['logstash'], | |
61 group => 'logstash', | |
62 mode => 0775, | |
63 owner => 'root', | |
64 require => [ | |
65 File[$adblockplus::log::directory], | |
66 Package['logstash'], | |
67 ], | |
68 } | |
69 | |
70 # The Python script dispatching incoming logs | |
71 file {$import_script: | |
72 ensure => 'present', | |
73 mode => 0755, | |
74 require => User[$adblockplus::log::user], | |
75 source => 'puppet:///modules/adblockplus/log/import.py', | |
76 } | |
77 | |
78 # See modules/adblockplus/manifests/log/uplink.pp | |
79 create_resources('adblockplus::log::uplink', $uplinks) | |
80 } | 38 } |
OLD | NEW |