CoffeeITWorks.ansible_nagios4_server_config

构建状态

角色名称

该角色配置 Nagios 并从 Git 仓库同步 Nagios 的配置。 此角色已准备好并与其他 ansiblecoffee Nagios 角色插件、thruk 界面、pnp4nagios 等兼容。

要求

没有特殊要求,只需保持系统更新。 目前仅在Ubuntu 14.04上测试。

角色分发支持

Ubuntu: 支持 RedHat: 不支持

角色变量

请查看 defaults/main.yml 中的所有内容。

添加到你的 host_vars 或 group_vars:

额外的 Nagios 配置选项

并添加到只读:

nagios_cgi_authorized_for_read_only: user1, user2

或者更改指定的权限:

nagios_cgi_authorized_for_system_information: nagiosadmin
nagios_cgi_authorized_for_configuration_information: nagiosadmin
nagios_cgi_authorized_for_system_commands: nagiosadmin
nagios_cgi_authorized_for_all_services: nagiosadmin,user1,user2
nagios_cgi_authorized_for_all_hosts: nagiosadmin,user1,user2
nagios_cgi_authorized_for_all_service_commands: nagiosadmin
nagios_cgi_authorized_for_all_host_commands: nagiosadmin

禁用不需要的主机上的通知,使用 host_vars/hostname

nagios_config_enable_notifications: 0

克隆仓库功能

如果你想,可以设置一些 Git 仓库以在指定的子目录中克隆配置,这是该角色的一个优秀特性。 你可以有多个仓库,例如:

  • 网络仓库,目录: "net"
  • 服务器仓库,目录: "servers"
  • 服务器服务仓库,目录: "services"

然后你可以重用其中的一些,或为其他主机添加不同的配置,如:

  • 没有服务检查的远程主机
  • 测试服务器,使用测试仓库,目录: "testing" 和所有之前的仓库。

然后你可以在 ansible-playbook 任务中使用 tag: "config_nagios" 来同步每次更新仓库时的所有服务器。

更好的是:使用类似 Jenkins 的 Git Hook 自动运行调用标签 config_nagios 的任务,每次将新配置推送到 Nagios 仓库时,所有服务器将自动同步。

示例:

nagios_config_cfg_dirs_git:
  - { repo: "http://server/user/repo.git", version: "master", dir: "repo"}
  - { repo: "http://users:password@server/user/repo2.git", version: "master", dir: "repo2"}

你也可以使用带有 SSH 密钥的其他变量:

首先在远程服务器上为 ansible 远程用户创建密钥目录

cd
mkdir keys

然后生成密钥并保存为 nagios_key_rsa

nagios_config_cfg_dirs_git_rsa:
  - { repo: "git@server:user/repo.git", version: "master", dir: "repo"}

当 nagios_config_cfg_dirs_git_rsa 变量存在时,该角色将查找 /home/remoteuser/keys/nagios_key_rsa 以使用它。

依赖关系

这里应该列出其他托管在 Galaxy 上的角色,以及有关可能需要为其他角色设置的参数或使用的变量的所有细节。

示例 Playbook

角色的完整列表:

- name: 应用 Nagios 设置
  hosts: nagios4_servers
  become: yes
  become_method: sudo
  roles:
    - { role: nagios4_server, tags: ["install", "nagios4_server_all", "nagios4_server"] }
    - { role: nagios4_server_plugins, tags: ["install", "nagios4_server_all", "nagios4_server_plugins"] }
    - { role: nagios4_server_pnp4nagios, tags: ["install", "nagios4_server_all", "nagios4_server_pnp4nagios"] }
    - { role: nagios4_server_snmptrap, tags: ["install", "nagios4_server_all", "nagios4_server_snmptrap"] }
    - { role: ANXS.mysql, tags: ["install", "nagios4_server_all", "nagios4_server_thruk", "ANXS.mysql"] }
    - { role: nagios4_server_thruk, tags: ["install", "nagios4_server_all", "nagios4_server_thruk"] }
    - { role: postfix_client, tags: ["install", "nagios4_server_all", "postfix_client"] }
# 其他标签: 角色/标签
# nagios4_server             - config_nagios
# nagios4_server             - nagios4_server_main_config
# nagios4_server             - config_nagios_cron
# nagios4_server_plugins     - config_nagios_plugins
# nagios4_server_plugins     - test_nagios_plugins
# nagios4_server_pnp4nagios  - test_nagios_pnp4nagios
# nagios4_server_thruk       - config_nagios_thruk_cron
# nagios4_server_thruk       - test_nagios_thruk
# nagios4_server_thruk_git   - config_nagios_thruk_git_cron

标签:

nagios4_server_main_config
nagios_config
config_nagios_cron

穿越防火墙

要让客户端连接到防火墙后的主机,必须打开以下端口:

TCP:

  • Ping: 主机存活
  • 5666: nrpe (Windows 和 Linux)
  • 1248: nsclient (仅 Windows)
  • 9666: 自定义 nrpe 当 5666 被使用时
  • 22: ssh 检查
  • 80,443: http, https 检查

UDP:

  • 161: SNMP 检查

许可证

BSD

作者信息

主要作者:Diego Daguerre,Pablo Estigarribia。 网站: https://github.com/ansiblecoffee

关于项目

Configure nagios, prepared to be compatible with thruk, pnp4nagios, nagios_plugins. Has feature to clone nagios config from git repos.

安装
ansible-galaxy install CoffeeITWorks.ansible_nagios4_server_config
许可证
mit
下载
474
拥有者
IT Works group