| OLD | NEW |
| 1 # == Class: adblockplus::log::master | 1 # == Class: adblockplus::log::master |
| 2 # | 2 # |
| 3 # A server setup to collect and pre-process log files. This is still a stub, | 3 # A server setup to collect and pre-process (i.e. anonymize and combine) |
| 4 # the generated configuration corresponds to recent package defaults. | 4 # log files using Logstash (https://logstash.net/) pipelines. |
| 5 # | 5 # |
| 6 # === Parameters: | 6 # === Parameters: |
| 7 # | 7 # |
| 8 # [*ensure*] | 8 # [*uplinks*] |
| 9 # Whether the master setup should be 'present' or 'absent', defaults | 9 # A hash of $name => $parameters resembling the servers registry within |
| 10 # to $adblockplus::log::ensure. | 10 # file modules/private/hiera/hosts.yaml, which is used by default. |
| 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 # }, |
| 15 # } | 21 # } |
| 16 # | 22 # |
| 17 class adblockplus::log::master ( | 23 class adblockplus::log::master ( |
| 18 $ensure = undef, | 24 $uplinks = hiera('adblockplus::log::master::uplinks', hiera('servers', {})), |
| 19 ) { | 25 ) { |
| 20 | 26 |
| 21 include adblockplus::log | 27 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 | |
| 29 realize(File[$adblockplus::log::directory]) | 28 realize(File[$adblockplus::log::directory]) |
| 30 realize(User[$adblockplus::log::user]) | 29 realize(User[$adblockplus::log::user]) |
| 31 | 30 |
| 32 # See modules/fluent/manifests/config.pp | 31 # Used as internal constants within adblockplus::log::* resources |
| 33 fluent::config {$title: | 32 $data_directory = "$adblockplus::log::directory/data" |
| 34 content => template('adblockplus/log/fluentd/master.conf.erb'), | 33 $uplink_directory = "$adblockplus::log::directory/uplink" |
| 35 ensure => pick($ensure, $adblockplus::log::ensure), | 34 $import_script = '/usr/local/bin/adblockplus-log-import' |
| 36 name => '50-adblockplus-log-master', | 35 |
| 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'), |
| 37 } | 42 } |
| 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) |
| 38 } | 80 } |
| OLD | NEW |