Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
- Puppet >= 6.0.0 < 8.0.0
- , , , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'jhoblitt-awstats', '1.0.0'Learn more about managing modules with a PuppetfileDocumentation
Puppet awstats Module
Table of Contents
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations
- Versioning
- Support
- Contributing
- See Also
Overview
Manages the AWStats HTTP/FTP/SMTP log analyzer
Description
"AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically." -- www.awstats.org
This is a puppet module for the installation and configuration of the AWStats package. It offers comprehensive configuration file generation and limited support for the enabling AWStats plugins.
Currently, this module relies on the package to enable periodic log processing.
The EPEL6package installs an hourly crontab that runs as root. This is
sub-optimal for security purposes as AWStats is a complex script but
understandable as historically logs have had root ownership. A future
release of this module may provide for AWStats to be invoked as a non-root
user.
Usage
Examples
Install awstats and configure apache
Example of configuring Apache for the AWStats CGI interface using the
puppetlabs/apache module.
$loadplugin = ['decodeutfkeys', 'geoip GEOIP_STANDARD /usr/share/GeoIP/GeoIP.dat']
$internal_hosts = 'REGEX[^192\.168\.] REGEX[^172\.16\.] REGEX[^10\.]'
include ::apache
apache::vhost { 'awstats.example.org':
port => '80',
docroot => '/usr/share/awstats/wwwroot',
serveraliases => ['awstats'],
aliases => [
{ alias => '/awstatsclasses', path => '/usr/share/awstats/wwwroot/classes/' },
{ alias => '/awstatscss', path => '/usr/share/awstats/wwwroot/css/' },
{ alias => '/awstatsicons', path => '/usr/share/awstats/wwwroot/icon/' },
],
scriptaliases => [
{ alias => '/awstats/', path => '/usr/share/awstats/wwwroot/cgi-bin/' },
],
directories => [{
path => '/usr/share/awstats/wwwroot',
provider => 'directory',
options => 'None',
order => 'Allow,Deny',
allow => 'from all',
#deny => 'from all',
}],
setenv => ['PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins'],
}
class { '::awstats':
config_dir_purge => true,
enable_plugins => [ 'DecodeUTFKeys', 'GeoIP' ],
}
# this ordering is needed for both the docroot path and so that the
# awstats package provided apache configuration snippet is purged on the
# first run
Class['::awstats'] -> Class['::apache']
Local apache log -- example 1
# apache log
awstats::conf { 'www.example.org':
options => {
'SiteDomain' => 'www.example.org',
'HostAliases' => 'localhost 127.0.0.1 example.org',
'LogFile' => 'sudo -iu loguser ssh loguser@example.org sudo cat /var/log/httpd/access_log |',
'AllowFullYearView' => 3,
'DNSLookup' => 1,
'SkipHosts' => $internal_hosts,
'LoadPlugin' => $loadplugin,
},
}
Local apache log -- example 2
Defaults to processing /var/log/httpd/access_log.
# apache log
awstats::conf { 'www.example.org': }
Which is equivalent to:
# apache log
awstats::conf { 'www.example.org':
options => { # defaults
'LogFile' => '/var/log/httpd/access_log',
'LogFormat' => '1',
'DirData' => '/var/lib/awstats',
'SiteDomain' => $::fqdn,
'HostAliases' => "localhost 127.0.0.1 ${::hostname}",
},
}
Remote apache log via ssh
# apache log
awstats::conf { 'www.example.org':
options => {
'SiteDomain' => 'www.example.org',
'HostAliases' => 'localhost 127.0.0.1 example.org',
'LogFile' => 'sudo -iu loguser ssh loguser@example.org sudo cat /var/log/httpd/access_log |',
'AllowFullYearView' => 3,
'DNSLookup' => 1,
'SkipHosts' => $internal_hosts,
'LoadPlugin' => $loadplugin,
},
}
Remote vsftp log via ssh
# vsftp log
awstats::conf { 'ftp.example.org':
options => {
'SiteDomain' => 'ftp.example.org',
'HostAliases' => 'localhost 127.0.0.1 example.org',
'LogFile' => 'sudo -iu loguser ssh loguser@example.org sudo cat /var/log/vsftpd.log |',
'LogFormat' => '%time3 %other %host %bytesd %url %other %other %method %other %logname %other %code %other %other',
'LogSeparator' => '\s',
'LogType' => 'F',
'AllowFullYearView' => 3,
'DNSLookup' => 1,
'SkipHosts' => $internal_hosts,
'LoadPlugin' => $loadplugin,
},
}
Remote pureftpd log via ssh
# pureftp log
awstats::conf { 'ftp.example.org':
options => {
'SiteDomain' => 'ftp.example.org',
'HostAliases' => 'localhost 127.0.0.1 example.org',
'LogFile' => 'sudo -iu loguser ssh loguser@example.org sudo cat /var/log/pureftpdstats.log |',
'LogFormat' => '%host %other %logname %time1 %methodurlnoprot %code %bytesd',
'LogSeparator' => '\s',
'LogType' => 'F',
'AllowFullYearView' => 3,
'DNSLookup' => 1,
'SkipHosts' => $internal_hosts,
'LoadPlugin' => $loadplugin,
},
}
Classes
awstats
# defaults
class { '::awstats':
config_dir_purge => false,
enable_plugins => [],
}
config_dir_purge
Boolean Default to: false
If set to true, unmanaged files in the configuration directory path,
typically /etc/awstats/ are purged.
enable_plugins
Array Defaults to: []
A case insensitive list of awstats plugins to enable "support" for by installing required dependencies. The supported plugins are:
- decodeutfkeys
- geoip
Defines
awstats::conf
# defaults
awstats::conf { '<title>':
template => undef,
options => {},
}
template
String Defaults to undef
The path to the puppet ERB template to use to generate the configuration file.
A value of undef is equivalent to ${module_name}/awstats.conf.erb.
options
Hash Defaults to {}
A hash of awstats configuration file options. The case of keys is preserved
and no validation of what is or isn't a valid awstats directive is performed.
The options hash is merged with these default values, which were determined to
be the minimum set of required parameters via trial and error with EPEL6
awstats-7.0-3.el6.noarch package. Please see the comments in
conf.pp for further details.
$default_options = {
'LogFile' => '/var/log/httpd/access_log',
'LogFormat' => '1',
'DirData' => '/var/lib/awstats',
'SiteDomain' => $::fqdn,
'HostAliases' => "localhost 127.0.0.1 ${::hostname}",
}
If a hash value is an array, multiple configuration file options with the same key name will be created. Eg.
options => {
'LoadPlugin' => ['foo', 'bar'],
}
Would result in the following options in the configuration file. Note that the order is sorted.
LoadPlugin="bar"
LoadPlugin="foo"
Reference
See REFERENCE
Limitations
This module has been developed around the awstats version 7 package from
EPEL6. A bit unfortunately, that package runs awstats.pl from cron as
root. Rather than fighting the package, that decision has been left in place
but may be revised in a future version of this module.
Versioning
This module is versioned according to the Semantic Versioning 2.0.0 specification.
Support
Please log tickets and issues at github
Contributing
- Fork it on github
- Make a local clone of your fork
- Create a topic branch. Eg,
feature/mousetrap - Make/commit changes
- Commit messages should be in imperative tense
- Check that linter warnings or errors are not introduced -
bundle exec rake lint - Check that
Rspec-puppetunit tests are not broken and coverage is added for new features -bundle exec rake spec - Documentation of API/features is updated as appropriate in the README
- If present,
beakeracceptance tests should be run and potentially updated -bundle exec rake beaker
- When the feature is complete, rebase / squash the branch history as necessary to remove "fix typo", "oops", "whitespace" and other trivial commits
- Push the topic branch to github
- Open a Pull Request (PR) from the topic branch onto parent repo's
masterbranch
See Also
Reference
Table of Contents
Classes
Public Classes
awstats: Install and configure awstats
Private Classes
awstats::plugin::decodeutfkeysawstats::plugin::geoip
Defined types
awstats::conf: manage awstats config file
Classes
awstats
Install and configure awstats
Parameters
The following parameters are available in the awstats class:
owner
Data type: String
awstats role user.
group
Data type: String
awstats role group.
config_dir_path
Data type: Stdlib::Absolutepath
Path of the awstats configuration directory.
packages
Data type: Optional[Array[String[1]]]
List of packages to install.
Default value: undef
config_dir_purge
Data type: Boolean
Default to: false
If set to true, unmanaged files in the configuration directory path,
typically /etc/awstats/ are purged.
Default value: false
enable_plugins
Data type: Array[String]
Defaults to: []
A case insensitive list of awstats plugins to enable "support" for by installing required dependencies. The supported plugins are:
- decodeutfkeys
- geoip
Default value: []
Defined types
awstats::conf
# defaults
awstats::conf { '<title>':
template => undef,
options => {},
}
$default_options = {
'LogFile' => '/var/log/httpd/access_log',
'LogFormat' => '1',
'DirData' => '/var/lib/awstats',
'SiteDomain' => $::fqdn,
'HostAliases' => "localhost 127.0.0.1 ${::hostname}"
}
If a hash value is an array, multiple configuration file options with the same key name will be created. Eg.
options => {
'LoadPlugin' => ['foo', 'bar'],
}
Would result in the following options in the configuration file. Note that the order is sorted.
LoadPlugin="bar"
LoadPlugin="foo"
Parameters
The following parameters are available in the awstats::conf defined type:
template
Data type: Optional[String]
Defaults to undef
The path to the puppet ERB template to use to generate the configuration file.
A value of undef is equivalent to ${module_name}/awstats.conf.erb.
Default value: undef
options
Data type: Hash
Defaults to {}
A hash of awstats configuration file options. The case of keys is preserved
and no validation of what is or isn't a valid awstats directive is performed.
The options hash is merged with these default values, which were determined to
be the minimum set of required parameters via trial and error with EPEL6
awstats-7.0-3.el6.noarch package.
Default value: {}
Dependencies
- puppetlabs/stdlib (>= 4.6.0 < 9.0.0)
Copyright (C) 2015 Joshua Hoblitt <jhoblitt@cpan.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.