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
- Puppet >=6.21.0 < 8.0.0
- , ,
Start using this module
Add this module to your Puppetfile:
mod 'trepasi-geoip', '6.0.1'
Learn more about managing modules with a PuppetfileDocumentation
GeoIP
Project status
Table of Contents
- GeoIP
Description
This Puppet module installs and maintains tools and processes to use GeoIP databases from MaxMind. These include the lookup tools for lookup and update the databases. It will manage the configuration for the update tool which enables to set up your subscription settings, product IDs and other settings, e.g. proxy settings. If systemd is available, a service is defined in order to enable a seamless update process.
Setup
What geoip affects
The module will install some packages, create a configuration file and a systemd service unit.
Setup Requirements
Neccesary packages must be available for installation by the package management tools used on the target system. As this is not the case on many systems, you have to take care about the availability of the packages. The list of the packages to be installed is a configuration option.
Beginning with geoip
The only thing to start with geoip is to include the class in the manifest of your nodes.
contain geoip
All configuration parameter can be assigned hiera. The default values are also lookuped up by hiera using the database shipped with the module.
Usage
Note, that MaxMind does not allow to download databases without subscription, but there is a free tier which can be used to download three GeoLite2 databases.
The configuration depends on the version of the geoipupdate
tool to use, as there is a difference between versions starting at 3.1.1 and the older ones. The module referns to these settings via parameter geoip::config_version
using the value lt311
for versions less than 3.1.1 and value ge311
for version greater or equal to 3.1.1.
Configuring versions less than 3.1.1
geoip::config:
userid: '<yourAccountID>'
licensekey: '<yourLicenseKey>'
Replace the values for userid
and licensekey
with actual data from your subscription.
Optional configuration settings are available, enable to set:
productids
: array of productids of the databases you want to download; it defaults to the freely available databases['GeoLite2-ASN', 'GeoLite2-City', 'GeoLite2-Country']
database_directory
: where to store the database filesprotocol
: HTTP or HTTPSproxy
: URL to the Proxy service allowing access to the Internetproxy_user_password
: Username and password to the Proxy, if needed.skip_hostname_verification
: Disable hostname verification.skip_peer_verification
: Disable certificate validation.
Refer to your subscription to get the list of productids
you are allowed to use.
Configuring versions 3.1.1 and later
geoip::config:
accountid: '<yourAccountID>'
licensekey: '<yourLicenseKey>'
Replace the values for accountid
and licensekey
with actual data from your subscription.
Optional configuration settings are available, enable to set:
editionids
: array of IDs of the databases you want to download; it defaults to the freely available databases['GeoLite2-ASN', 'GeoLite2-City', 'GeoLite2-Country']
database_directory
: where to store the database fileshost
: the update server to useproxy
: URL to the Proxy service allowing access to the Internetproxy_user_password
: Username and password to the Proxy, if needed.lock_file
: location of the lock file to use to prevent running multiple updates at the same time
Refer to your subscription to get the list of editionids
you are allowed to use.
Upgrading to 3.1.1 or later
Versions of geoipupdate
3.1.1 or later will accept the configuration file format of former versions. Making use of that, the module provides the geoip::config_version
parameter to chose the configuration format, which defaults to lt311
, but is overwritten with ge311
for operating system versions known to provide geoipupdate version 3.1.1 or later (e.g. Debian Buster). While it should not needed to set this parameter in normal operation, during upgrade of multiple nodes, the parameter allows to pin the configuration version to the needed format.
Note, that a license keys issued for versions less than 3.1.1 of later will not work in both configurations, geoipupdate
versions less than 3.1.1 will fail accessing the update server when a key issed for 3.1.1 or later is provided in the lt311
configuration.
Updating databases
In order to update your databases you may use the geoipupdate
tool with the configuration file created by this puppet module.
If you haven't disabled geoip::manage_service
, you may start the update service named geoip::service_name
(defaults to geoip_update
), which will do the update.
By default, the update service will retry after 5 minutes if the update was failed by any reason. This behaviour can be changed via geoip::systemd::service::restart
and geoip::systemd::service::restart_sec
defining SystemD restart behaviour.
Update scheduling
Updates, if handled by SystemD, can be scheduled by setting geoip::update_timers
an array of timer descriptions. These timer descriptions apply on systemd timer unit OnCalendar options. For correct syntax of these timestamps see systemd.time(7)#Parsing Timestamps.
The parameter geoip::update_scatter
defines the seconds for systemd timer AccuracySec option (see systemd.timer(5)#AccuracySec) to prevent multiple nodes to update at the same time.
Reference
Automatically generated reference documentation is available in the REFERENCE.md file or at https://rtib.github.io/puppet-geoip/.
Limitations
For supported operating systems and dependencies, see metadata.json.
Extensive itegration tests are run nightly to assure quality and compatibility with next releases.
Debian 11 - Bullseye
The geoipupdate
package available in Debian Bullseye release is shipping SystemD units for service and timer to conduct weekly updates of the database. Default behaviour of the module will shift to use systemd_config: dropin
on Debian-11 by default to rebuild the functionality on the changed environment.
Development
The module is developed using recent Puppet Development Kit, validated and extensively tested using Puppet Litmus. Automated workflows, implemented with GitHub Actions are run on demand and nightly, doing validation, spec tests and continuous integration tests.
Note, that CI-Acceptance workflow is not applied to pull requests automatically, as it needs credentials setup as secrets to work. A pull request, however, will only be merged if these tests also succeed.
As an open project, you are welcome to contribute to this module. Currently, there is no contribution guide specific to this module, general information about the workflow may apply. In case of questions feel free to open a issue or join community Slack channels #forge-modules, #puppet, #puppet-dev, #testing on slack.puppet.com.
Issues and pull requests will be addressed in a timely manner, according to community best practice. Releases are going to be published on demand, after having merged an set of sufficiently important changes and all tests succeeded. There may be automated rule enforcement in place to provide a healthy issue lifecycle.
Copyright
This product is tested using GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
Reference
Table of Contents
Classes
geoip
: The geoip module installs tools and databases GeoIP resolution from MaxMind. You may replace userid and licensekey with your subscription angeoip::config
: This class implements the configuration stage of this module. It should not be called directly. Configuration file defined with `geoip::confgeoip::config::ge311
: This class is creating a GeoIP.conf configuration file for geoipupdate versions >= 3.1.1.geoip::config::lt311
: This class is creating a GeoIP.conf configuration file for geoipupdate versions < 3.1.1.geoip::install
: This class implements the installation stage of the module. It should not be called directly. This will install or remove software packagesgeoip::service
: This class implements the service control stage of the module. It should not be called directly. Ifgeoip::manage_service
enabled, an updageoip::systemd::service
: Controling SystemD service unit for updategeoip::systemd::timer
: Controll the SystemD Timer unit
Classes
geoip
The geoip module installs tools and databases GeoIP resolution from MaxMind.
You may replace userid and licensekey with your subscription and add the productids you want to sync. Leaving these options on default will allow you to sync all free available databases. With database_directory the destination directory of the databases can be set, protocol, proxy and _verification may only be needed in the case your host needs some specific proxy settings to get to the internet.
Examples
hiera
geoip::config:
userid: '999999'
licensekey: '000000000000'
productids:
- GeoLite2-City
- GeoLite2-Country
database_directory:
protocol:
proxy:
proxy_user_password:
skip_hostname_verification:
skip_peer_verification:
Parameters
The following parameters are available in the geoip
class:
ensure
packages
package_ensure
config_path
config_version
config
manage_service
systemd_config
service_user
service_group
update_path
service_name
update_timers
update_scatter
ensure
Data type: Enum['present', 'absent']
install or remove settings done by this module
Default value: 'present'
packages
Data type: Array[String]
the software packages containing the tools to be installed
Default value: ['mmdb-bin', 'geoipupdate']
package_ensure
Data type: String
which version of the packages should be ensured
Default value: 'latest'
config_path
Data type: Stdlib::Absolutepath
path to the configuration and license file
Default value: '/etc/GeoIP.conf'
config_version
Data type: Enum['lt311','ge311']
the config version to use for geoipupdate
Default value: 'lt311'
config
Data type: Hash
hash of configuration options
Default value: {}
manage_service
Data type: Boolean
whether to manage database updating service
Default value: true
systemd_config
Data type: Enum['unit', 'dropin']
type of configuration how changes are applied to systemd
Default value: 'unit'
service_user
Data type: String
effective user the update service should run
Default value: 'root'
service_group
Data type: String
effective group the update service should run
Default value: 'root'
update_path
Data type: Stdlib::Absolutepath
path to the geoipupdate tool, used by update service
Default value: '/usr/bin/geoipupdate'
service_name
Data type: String
name of the update service
Default value: 'geoip_update'
update_timers
Data type: Array[String]
wallclock timers when the update service should be triggered (for syntax see systemd.time(7)#Parsing Timestamps)
Default value: []
update_scatter
Data type: Integer
a time window in seconds of randomized, host specific delay of the update trigger (see systemd.timer(5)#AccuracySec)
Default value: 1800
geoip::config
This class implements the configuration stage of this module. It should not be called directly.
Configuration file defined with geoip::config_path
will be created using parameter from
geoip::config
.
geoip::config::ge311
This class is creating a GeoIP.conf configuration file for geoipupdate versions >= 3.1.1.
Parameters
The following parameters are available in the geoip::config::ge311
class:
accountid
licensekey
editionids
database_directory
host
proxy
proxy_user_password
preserve_file_times
lock_file
accountid
Data type: String
AccountID of your MaxMind subscription
licensekey
Data type: String
The license key issued by MaxMind to be used
editionids
Data type: Array[String]
Edition IDs (formerly known as ProductIDs) to download
Default value: ['GeoLite2-ASN','GeoLite2-City','GeoLite2-Country']
database_directory
Data type: Optional[Stdlib::Absolutepath]
Path where the database file to be stored
Default value: undef
host
Data type: Optional[String]
The update server to use
Default value: undef
proxy
Data type: Optional[String]
URL or IP:Port of the proxy to use when accessing the update server
Default value: undef
proxy_user_password
Data type: Optional[String]
Credentials as username:password for proxy authentication
Default value: undef
preserve_file_times
Data type: Optional[Boolean]
Whether to preserve modification times of files downloaded from the server
Default value: undef
lock_file
Data type: Optional[String]
The lock file to use
Default value: undef
geoip::config::lt311
This class is creating a GeoIP.conf configuration file for geoipupdate versions < 3.1.1.
Parameters
The following parameters are available in the geoip::config::lt311
class:
userid
licensekey
productids
database_directory
protocol
proxy
proxy_user_password
skip_hostname_verification
skip_peer_verification
userid
Data type: String
UserID of your MaxMind subscription
licensekey
Data type: String
The license key issued by MaxMind to be used
productids
Data type: Array[String]
Product IDs to download
Default value: ['GeoLite2-ASN','GeoLite2-City','GeoLite2-Country']
database_directory
Data type: Optional[Stdlib::Absolutepath]
Path where the database file to be stored
Default value: undef
protocol
Data type: Optional[Enum['http','https']]
Protocol to be used when accessing the update server
Default value: undef
proxy
Data type: Optional[String]
URL or IP:Port of the proxy to use when accessing the update server
Default value: undef
proxy_user_password
Data type: Optional[String]
Credentials as username:password for proxy authentication
Default value: undef
skip_hostname_verification
Data type: Optional[Boolean]
Whether to skip host name verification on HTTPS connections
Default value: undef
skip_peer_verification
Data type: Optional[Boolean]
Whether to skip peer verification on HTTPS connections
Default value: undef
geoip::install
This class implements the installation stage of the module. It should not be called directly.
This will install or remove software packages listed in geoip::packages
. When installing
package versions will be ensured as geoip::package_ensure
.
geoip::service
This class implements the service control stage of the module. It should not be called directly.
If geoip::manage_service
enabled, an update service will be created fitting to the service
provider available on the node. Service name is configured with geoip::service_name
.
geoip::systemd::service
This class is creating a serivce unit for SystemD to update GeoIP databases. The service is running the geoipupdate ones and retry as configured.
Parameters
The following parameters are available in the geoip::systemd::service
class:
restart
Data type: String
update service retry behaviour
Default value: 'on-failure'
restart_sec
Data type: String
time to wait before retry
Default value: '5min'
geoip::systemd::timer
This class will create a SystemD timer unit triggering the update service on each wallclock timer.
Parameters
The following parameters are available in the geoip::systemd::timer
class:
overwrite_wallclocks
Data type: Boolean
if systemd_config is set to dropin, the existing timer may already have wallclocks, this aboud to overwrite or append them
Default value: true
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
v6.0.1 - 2023-07-18
Other
v6.0.0 - 2023-06-28
Added
Changed
v5.0.1 - 2023-01-03
v5.0.0 - 2023-01-03
Changed
v4.1.0 - 2021-10-04
Added
Fixed
- fix acceptance test #43 (rtib)
- [MODULES-11118] enforce template conformance to meet requirements #40 (rtib)
v4.0.1 - 2021-09-10
Fixed
v4.0.0 - 2021-09-02
Added
Changed
v3.2.1 - 2021-08-03
Fixed
v3.2.0 - 2021-06-25
Added
Fixed
v3.1.0 - 2021-06-16
Added
v3.0.1 - 2021-05-26
Fixed
v3.0.0 - 2021-05-03
Changed
v2.2.0 - 2021-03-25
Added
Fixed
v2.1.1 - 2020-06-19
Fixed
v2.1.0 - 2020-05-05
Added
- direct stdout and stderr to systemd journal #22 (rtib)
- Restart update service on abnormal termination #21 (rtib)
v2.0.0 - 2020-02-14
Added
- simplifying and documenting things #16 (rtib)
- Add support for Debian-10 #15 (rtib)
- Add support for geoipupdate version 3.1.1 configuration file #14 (rtib)
Changed
Fixed
v1.0.1 - 2018-12-19
Fixed
v1.0.0 - 2018-12-19
Changed
v0.2.0 - 2018-12-07
Added
Fixed
v0.1.1 - 2018-11-30
Dependencies
- puppetlabs/stdlib (>= 4.13.1 < 10.0.0)
- puppet/systemd (>= 3.1.0 < 6.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] 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.