Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/fluent/manifests/init.pp

Issue 29338665: Issue 3694 - Introduce module fluent (Closed)
Patch Set: Created March 18, 2016, 6:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « modules/fluent/manifests/gem.pp ('k') | modules/fluent/manifests/plugin.pp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # == Class: fluent
2 #
3 # Create and maintain Fluentd (https://www.fluentd.org/) setups.
4 #
5 # == Parameters:
6 #
7 # [*config*]
8 # Overwrite the default concat/file options for the Fluentd agent config.
9 #
10 # [*key*]
11 # Overwrite the default apt::key used (given Class['apt'] is defined).
12 #
13 # [*package*]
14 # Overwrite the default package options, to fine-tune the target version (i.e.
15 # ensure => 'latest') or remove Fluentd (ensure => 'absent' or 'purged')
16 #
17 # [*service*]
18 # Overwrite the default service options.
19 #
20 # [*source*]
21 # Overwrite the default apt::source used (given Class['apt'] is defined).
22 #
23 # [*user*]
24 # Overwrite the default user options, i.e. to provide a $HOME directory.
25 #
26 # === Examples:
27 #
28 # class {'fluent':
29 # package => {
30 # ensure => 'latest',
31 # },
32 # user => {
33 # managehome => true,
34 # shell => '/bin/sh',
35 # },
36 # }
37 #
38 # class {'fluent':
39 # package => {
40 # ensure => 'absent',
41 # },
42 # }
43 #
44 class fluent (
45 $config = {
46 content => template('fluent/td-agent.conf.erb'),
47 },
48 $key = {
49 key => 'A12E206F',
50 key_content => template("fluent/td-gpg-key.erb"),
51 },
52 $package = {},
53 $service = {},
54 $source = {
55 location => sprintf(
56 'https://packages.treasuredata.com/2/%s/%s',
57 downcase($lsbdistid), downcase($lsbdistcodename)
58 ),
59 release => downcase($lsbdistcodename),
60 repos => 'contrib',
61 },
62 $user = {},
63 ) {
64
65 include stdlib
66
67 ensure_resource('package', $title, merge({
68 name => 'td-agent',
69 }, $package))
70
71 # Used as default $ensure parameter for most resources below
72 $ensure = getparam(Package[$title], 'ensure') ? {
73 /^(absent|purged|held)$/ => 'absent',
74 default => 'present',
75 }
76
77 ensure_resource('file', $title, merge({
78 ensure => $ensure,
79 group => 'root',
80 mode => '0644',
81 owner => 'root',
82 path => '/etc/td-agent/td-agent.conf',
83 }, $config))
84
85 ensure_resource('user', $title, merge({
86 ensure => $ensure,
87 name => 'td-agent',
88 gid => 'td-agent',
89 home => '/home/td-agent',
90 shell => '/bin/false',
91 }, $user))
92
93 Package[$title] -> File[$title]
94 Package[$title] -> User[$title]
95
96 # Used as internal shortcuts within fluent::* resource definitions
97 $directory = regsubst(getparam(File[$title], 'path'), '/[^/]+$', '')
98 $group = getparam(User[$title], 'gid')
99
100 # Service resources don't properly support the concept of absence
101 if ($ensure == 'present') or ($service['ensure'] != undef) {
102
103 ensure_resource('service', $title, merge({
104 name => 'td-agent',
105 }, $service))
106
107 Service[$title] <~ File[$title]
108 Service[$title] <~ Package[$title]
109 Service[$title] <~ User[$title]
110 }
111
112 # Base directories for fluent::config and fluent::plugin resources
113 file {[
114 "$directory/config.d",
115 "$directory/plugin",
116 ]:
117 before => File[$title],
118 ensure => getparam(File[$title], 'ensure') ? {
119 /^(present|link)$/ => 'directory',
120 default => 'absent',
121 },
122 group => getparam(File[$title], 'group'),
123 mode => 0755,
124 owner => getparam(File[$title], 'owner'),
125 require => Package[$title],
126 }
127
128 # The only package provider recognized implicitly
129 if getparam(Package[$title], 'provider') == 'apt' {
130
131 ensure_resource('apt::key', $title, merge({
132 ensure => $ensure,
133 name => 'treasure-data',
134 }, $key))
135
136 ensure_resource('apt::source', $title, merge({
137 ensure => $ensure,
138 include_src => false,
139 name => 'treasure-data',
140 }, $source))
141
142 Apt::Source[$title] <- Apt::Key[$title]
143 Apt::Source[$title] -> Package[$title]
144 }
145 }
OLDNEW
« no previous file with comments | « modules/fluent/manifests/gem.pp ('k') | modules/fluent/manifests/plugin.pp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld