honzamach.geoip

角色 geoip

  • Ansible Galaxy 页面 <https://galaxy.ansible.com/honzamach/geoip>__
  • GitHub 仓库 <https://github.com/honzamach/ansible-role-geoip>__
  • Travis CI 页面 <https://travis-ci.org/honzamach/ansible-role-geoip>__

这是一个 Ansible 角色,用于方便安装由 MaxMind <https://www.maxmind.com/en/home>__ 提供的免费 IP 地理位置数据库 GeoLite2 <https://dev.maxmind.com/geoip/geoip2/geolite2/#Download_Access>__。

目录:

  • :ref:section-role-geoip-installation
  • :ref:section-role-geoip-dependencies
  • :ref:section-role-geoip-usage
  • :ref:section-role-geoip-variables
  • :ref:section-role-geoip-files
  • :ref:section-role-geoip-author

该角色是 MSMS <https://github.com/honzamach/msms>__ 包的一部分。 一些常见功能在其 :ref:手册 <section-manual> 中有说明。

安装

要从 Ansible Galaxy <https://galaxy.ansible.com/>__ 安装角色 honzamach.geoip <https://galaxy.ansible.com/honzamach/geoip>__,请使用以下命令变体::

ansible-galaxy install honzamach.geoip

要通过克隆 ansible-role-geoip <https://github.com/honzamach/ansible-role-geoip>__ 仓库直接从 GitHub <https://github.com>__ 安装角色,请使用以下命令变体::

git clone https://github.com/honzamach/ansible-role-geoip.git honzamach.geoip

目前,直接使用 Git 克隆的优点是能够在新版本发布时轻松更新该角色。

依赖关系

该角色不依赖于其他任何角色。

以下角色依赖于此角色:

  • :ref:mentat <section-role-mentat>
  • :ref:mentat_dev <section-role-mentat-dev>

使用

示例清单文件 inventory 的内容::

[servers_geoip]
your-server

示例角色剧本文件 role_playbook.yml 的内容::

- hosts: servers_geoip
  remote_user: root
  roles:
    - role: honzamach.geoip
  tags:
    - role-geoip

示例用法::

# 运行所有内容:
ansible-playbook --ask-vault-pass --inventory inventory role_playbook.yml

建议遵循以下配置原则:

  • 创建/编辑文件 inventory/group_vars/all/vars.yml,并在其中为所有管理服务器定义一些合理的默认值。例如::

      hm_geoip__account_id: "{{ vault_hm_geoip__account_id }}"
      hm_geoip__license_key: "{{ vault_hm_geoip__license_key }}"
    
  • 创建/编辑 :ref:vault <section-overview-vault> 加密文件 inventory/group_vars/all/vault.yml, 并在其中存储备份加密密码::

      vault_hm_geoip__account_id: 123456
      vault_hm_geoip__license_key: something-so-secret-no1-is-gonna-guess
    
  • 使用文件 inventory/host_vars/[your-server]/vars.yml 自定义特定服务器的设置。 请参见 :ref:section-role-geoip-variables 部分以获取所有可用选项。

配置变量

内部角色变量


.. envvar:: hm_geoip__package_url

    用于安装 geoipupdate 工具的默认包 URL。

    * *数据类型:* ``string``
    * *默认值:* ``https://github.com/maxmind/geoipupdate/releases/download/v4.1.5/geoipupdate_4.1.5_linux_amd64.deb``

.. envvar:: hm_geoip__account_id

    您的 MaxMind 账户唯一标识符(数字)。

    * *数据类型:* ``integer``
    * *默认值:* ``null``

.. envvar:: hm_geoip__license_key

    您的 MaxMind 账户许可证密钥。在生成密钥时,确保已启用 *Update* 选项。

    * *数据类型:* ``string``
    * *默认值:* ``null``

.. envvar:: hm_geoip__edition_ids

    要在目标主机上安装的 IP 地理位置数据库列表。

    * *数据类型:* ``list of strings``
    * *默认值:* ``["GeoLite2-ASN", "GeoLite2-City", "GeoLite2-Country"]``

.. envvar:: hm_geoip__database_directory

    存储数据库文件的目录。

    * *数据类型:* ``string``
    * *默认值:* ``/usr/share/GeoIP``


内置的 Ansible 变量

.. envvar:: ansible_lsb['codename']

Debian 发行版代号用于 :ref:`模板自定义 <section-overview-role-customize-templates>` 功能。

管理文件

.. note::

此角色支持 :ref:`模板自定义 <section-overview-role-customize-templates>` 功能。

此角色管理目标系统上以下文件的内容:

  • /etc/cron.d/geoipupdate [模板]
  • /etc/GeoIP.conf [模板]

作者和许可证

| 版权: (C) 自 2019 年以来 Honza Mach honza.mach.ml@gmail.com | 作者: Honza Mach honza.mach.ml@gmail.com | 使用此角色受 MIT 许可证约束,详见 LICENSE 文件。

关于项目

Ansible role for convenient installation of the free IP geolocation databases GeoLite2 provided by MaxMind.

安装
ansible-galaxy install honzamach.geoip
许可证
mit
下载
169
拥有者