OLD | NEW |
| (Empty) |
1 class statsmaster::awstats { | |
2 package {['awstats', 'libgeo-ip-perl']:} | |
3 | |
4 file {['/var/www/awstatsdata', '/var/www/awstatsdatadaily', | |
5 '/var/www/awstatsconf', '/var/www/awstats', | |
6 '/var/www/awstats/archive', '/var/www/awstats/daily']: | |
7 ensure => directory, | |
8 owner => root, | |
9 mode => 0755, | |
10 } | |
11 | |
12 file {'/etc/cron.d/awstats': | |
13 # AWStats package thinks that running AWStats without proper configuration | |
14 # every 10 minutes is a good idea. | |
15 ensure => absent, | |
16 } | |
17 | |
18 concat {'/var/www/awstats/index.html': | |
19 mode => 0644, | |
20 owner => root, | |
21 } | |
22 | |
23 concat {['/home/stats/process_logs', '/home/stats/build_static', | |
24 '/home/stats/anonymize_ips']: | |
25 owner => stats, | |
26 mode => 0700, | |
27 } | |
28 | |
29 concat::fragment {'index_head': | |
30 target => '/var/www/awstats/index.html', | |
31 content => template('statsmaster/index_head.html.erb'), | |
32 order => 'aaahead', | |
33 } | |
34 | |
35 concat::fragment {'index_foot': | |
36 target => '/var/www/awstats/index.html', | |
37 content => template('statsmaster/index_foot.html.erb'), | |
38 order => 'zzzfoot', | |
39 } | |
40 | |
41 concat::fragment {'process_logs_head': | |
42 target => '/home/stats/process_logs', | |
43 content => template('statsmaster/process_logs_head.erb'), | |
44 order => 'aaahead', | |
45 } | |
46 | |
47 concat::fragment {'build_static_head': | |
48 target => '/home/stats/build_static', | |
49 content => template('statsmaster/build_static_head.erb'), | |
50 order => 'aaahead', | |
51 } | |
52 | |
53 concat::fragment {'anonymize_ips_head': | |
54 target => '/home/stats/anonymize_ips', | |
55 content => template('statsmaster/anonymize_ips_head.erb'), | |
56 order => 'aaahead', | |
57 } | |
58 | |
59 define siteconfig($host, $log) { | |
60 file {"/var/www/awstatsconf/awstats.$title.conf": | |
61 ensure => present, | |
62 mode => 0444, | |
63 owner => root, | |
64 content => template('statsmaster/awstats.conf'), | |
65 } | |
66 | |
67 file {["/var/www/awstatsdata/$title", "/var/www/awstatsdatadaily/$title", | |
68 "/var/www/awstats/$title", "/var/www/awstats/archive/$title", | |
69 "/var/www/awstats/daily/$title"]: | |
70 ensure => directory, | |
71 mode => 0755, | |
72 owner => stats, | |
73 } | |
74 | |
75 concat::fragment {"index_$title": | |
76 target => '/var/www/awstats/index.html', | |
77 content => template('statsmaster/index_item.html.erb'), | |
78 order => $title, | |
79 } | |
80 | |
81 concat::fragment {"process_logs_$title": | |
82 target => '/home/stats/process_logs', | |
83 content => template('statsmaster/process_logs_item.erb'), | |
84 order => $title, | |
85 } | |
86 | |
87 concat::fragment {"build_static_$title": | |
88 target => '/home/stats/build_static', | |
89 content => template('statsmaster/build_static_item.erb'), | |
90 order => $title, | |
91 } | |
92 | |
93 concat::fragment {"anonymize_ips_$title": | |
94 target => '/home/stats/anonymize_ips', | |
95 content => template('statsmaster/anonymize_ips_item.erb'), | |
96 order => $title, | |
97 } | |
98 } | |
99 | |
100 $sites = { | |
101 'adblockplus.org' => { | |
102 host => 'web2.adblockplus.org', | |
103 log => 'access_log_adblockplus.org', | |
104 }, | |
105 'share.adblockplus.org' => { | |
106 host => 'web-sh-abp-org-1.adblockplus.org', | |
107 log => 'access_log_share.adblockplus.org', | |
108 }, | |
109 'facebook.adblockplus.me' => { | |
110 host => 'web-fb-abp-me-1.adblockplus.org', | |
111 log => 'access_log_facebook.adblockplus.me', | |
112 }, | |
113 'youtube.adblockplus.me' => { | |
114 host => 'web-yt-abp-me-1.adblockplus.org', | |
115 log => 'access_log_youtube.adblockplus.me', | |
116 }, | |
117 'acceptableads.org' => { | |
118 host => 'web-aa-org-1.adblockplus.org', | |
119 log => 'access_log_acceptableads.org', | |
120 }, | |
121 'eyeo.com' => { | |
122 host => 'web1.adblockplus.org', | |
123 log => 'access_log_eyeo.com', | |
124 }, | |
125 'intraforum.adblockplus.org' => { | |
126 host => 'server10.adblockplus.org', | |
127 log => 'access_log_intraforum', | |
128 }, | |
129 } | |
130 | |
131 create_resources(statsmaster::awstats::siteconfig, $sites) | |
132 | |
133 # | |
134 # IMPORTANT: This will only work correctly if the following bugs are fixed | |
135 # in your AWStats instance (might require manual patching): | |
136 # | |
137 # * https://sourceforge.net/p/awstats/bugs/873/ | |
138 # * https://sourceforge.net/p/awstats/bugs/929/ | |
139 # | |
140 | |
141 cron {'awstats_update': | |
142 ensure => present, | |
143 require => [ | |
144 Package['awstats', 'libgeo-ip-perl'], | |
145 File['/home/stats/process_logs', '/home/stats/build_static', | |
146 '/var/www/awstatsdata', '/var/www/awstatsdatadaily', | |
147 '/var/www/awstats', '/var/www/awstatsconf'], | |
148 ], | |
149 command => '/home/stats/process_logs && /home/stats/build_static', | |
150 user => stats, | |
151 hour => 4, | |
152 minute => 0, | |
153 } | |
154 | |
155 cron {'awstats_prevmonth': | |
156 ensure => present, | |
157 require => [ | |
158 Package['awstats'], | |
159 File['/home/stats/build_static', '/home/stats/anonymize_ips', | |
160 '/var/www/awstatsdata', '/var/www/awstatsdatadaily', | |
161 '/var/www/awstatsconf', '/var/www/awstats'], | |
162 ], | |
163 command => '/home/stats/anonymize_ips prevmonth && /home/stats/build_static
prevmonth', | |
164 user => stats, | |
165 monthday => 1, | |
166 hour => 6, | |
167 minute => 0, | |
168 } | |
169 } | |
OLD | NEW |