telekom_mms.icinga_director.icinga_host_template 模块 – 在 Icinga2 中管理主机模板

注意

此模块是 telekom_mms.icinga_director 集合(版本 2.2.1)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install telekom_mms.icinga_director

要在 playbook 中使用它,请指定:telekom_mms.icinga_director.icinga_host_template

telekom_mms.icinga_director 1.2.0 中的新功能

概要

  • 通过 director API 在 Icinga2 中添加或删除主机模板。

参数

参数

注释

accept_config

boolean

在 telekom_mms.icinga_director 1.9.0 中添加

代理是否配置为接受配置。

选项

  • false

  • true

address

string

主机地址。通常是 IPv4 地址,但也可能是你的检查插件能够处理的任何类型的地址。

address6

string

主机 IPv6 地址。通常是 IPv6 地址,但也可能是你的检查插件能够处理的任何类型的地址。

append

boolean

在 telekom_mms.icinga_director 1.25.0 中添加

不要覆盖整个对象,而是追加定义的属性。

注意 - 无法追加到现有的 vars、imports 或任何其他列表/字典。你必须覆盖完整的列表/字典。

注意 - 默认设置的变量也将被应用,即使未设置。

选项

  • false

  • true

check_command

string

检查命令的名称。

虽然这不是必须在 director 中定义的,但你仍然必须在主机或主机模板中提供 check_command。

check_interval

string

你的常规检查间隔。

check_period

string

时间段的名称,用于确定应何时监视此对象。默认情况下不受限制。

check_timeout

string

检查命令超时时间(以秒为单位)。覆盖 CheckCommand 的 timeout 属性

client_cert

path

用于 SSL 客户端身份验证的 PEM 格式证书链文件。

此文件也可以包含密钥,如果包含密钥,则不需要 client_key

client_key

path

包含用于 SSL 客户端身份验证的私钥的 PEM 格式文件。

如果 client_cert 同时包含证书和密钥,则不需要此选项。

command_endpoint

string

命令在其上执行的端点。

disabled

boolean

已禁用对象将不会被部署。

选项

  • false ←(默认)

  • true

display_name

string

此主机的备用名称。可能是主机别名或帮助用户识别此主机的任何类型的字符串。

enable_active_checks

boolean

是否主动检查此对象。

选项

  • false

  • true

enable_event_handler

boolean

是否启用此对象的事件处理程序。

选项

  • false

  • true

enable_flapping

boolean

是否在此对象上启用抖动检测。

选项

  • false

  • true

enable_notifications

boolean

是否为此对象发送通知。

选项

  • false

  • true

enable_passive_checks

boolean

是否接受此对象的被动检查结果。

选项

  • false

  • true

enable_perfdata

boolean

是否处理此对象提供的性能数据。

选项

  • false

  • true

event_command

string

主机的事件命令,如果匹配以下条件之一,则在每次检查执行时调用

主机处于软状态

主机状态更改为硬状态

主机状态从软状态或硬状态恢复为 OK/Up

flapping_threshold_high

string

服务被视为抖动的抖动上限(以百分比表示)

flapping_threshold_low

string

服务被视为不抖动的抖动下限(以百分比表示)

force

boolean

如果为 yes,则不要获取缓存的副本。

选项

  • false ←(默认)

  • true

force_basic_auth

boolean

使用 url_usernameurl_password 指定的凭据应在 HTTP 标头中传递。

选项

  • false ←(默认)

  • true

groups

list / elements=string

应直接分配给此节点的 Hostgroups。Hostgroups 由于各种原因很有用。

你可能会根据分配的 hostgroup 分配服务检查。它们通常也用作在 Icinga Web 2 中强制执行受限视图的工具。

Hostgroups 可以直接分配给单个主机或主机模板。

你可能还想考虑使用应用规则分配 hostgroups。

默认值: []

has_agent

boolean

在 telekom_mms.icinga_director 1.9.0 中添加

此主机是否安装了 Icinga 2 Agent。

选项

  • false

  • true

http_agent

string

用于标识的标头,通常出现在 Web 服务器日志中。

默认值: "ansible-httpget"

icon_image

string

指向此对象图标的 URL。

尝试使用 “tux.png” 作为相对于 public/img/icons 的图标,或使用 “cloud”(无扩展名)作为 Icinga 图标字体中的项目

icon_image_alt

string

在上述图标缺失的情况下显示的备用文本

imports

list / elements=string

选择一个主机模板。

master_should_connect

boolean

在 telekom_mms.icinga_director 1.9.0 中添加

父(主)节点是否应主动尝试连接到此代理。

选项

  • false

  • true

max_check_attempts

string

定义在多少次检查尝试后达到新的硬状态。

notes

string

在 telekom_mms.icinga_director 1.8.0 中添加

此对象的其他注释。

notes_url

string

在 telekom_mms.icinga_director 1.8.0 中添加

指向此对象的其他注释的 URL。

像这样分隔多个 URL “’http://url1’ ‘http://url2’”。

最大长度为 255 个字符。

object_name

别名:name

字符串 / 必选

此主机模板的 Icinga 对象名称。

这通常是完全限定的主机名,但基本上可以是任何字符串。

为了方便您的用户,我们强烈建议为模板使用有意义的名称。

例如,“generic-host” 显得很丑陋,“Standard Linux Server” 更容易理解。

retry_interval

string

重试间隔,将在状态更改后应用,除非达到下一个硬状态。

state

string

应用功能状态。

选项

  • "present" ← (默认)

  • "absent"

url

字符串 / 必选

HTTP、HTTPS 或 FTP URL,格式为 (http|https|ftp)://[user[:pass]]@host.domain[:port]/path

url_password

string

用于 HTTP 基本身份验证的密码。

如果未指定 url_username 参数,则不会使用 url_password 参数。

url_username

string

用于 HTTP 基本身份验证的用户名。

对于允许空密码的站点,此参数可以不使用 url_password

use_gssapi

boolean

在 ansible-core 2.11 中添加

使用 GSSAPI 执行身份验证,通常用于 Kerberos 或通过协商进行的 Kerberos 身份验证。

需要安装 Python 库 gssapi

GSSAPI 的凭据可以使用 url_username/url_password 指定,也可以使用指定自定义 Kerberos 凭据缓存的 GSSAPI 环境变量 KRB5CCNAME

即使已安装 NTLM 的 GSSAPI 机制,也 支持 NTLM 身份验证。

选项

  • false ←(默认)

  • true

use_proxy

boolean

如果为 no,则不会使用代理,即使在目标主机上的环境变量中定义了代理。

选项

  • false

  • true ← (默认)

validate_certs

boolean

如果为 no,则不会验证 SSL 证书。

这只应在个人控制的使用自签名证书的站点上使用。

选项

  • false

  • true ← (默认)

vars

字典

主机的自定义属性。

volatile

boolean

此检查是否为易失性。

选项

  • false

  • true

zone

string

设置区域。

注释

注意

  • 此模块支持检查模式。

示例

- name: Create host template
  telekom_mms.icinga_director.icinga_host_template:
    state: present
    url: "{{ icinga_url }}"
    url_username: "{{ icinga_user }}"
    url_password: "{{ icinga_pass }}"
    accept_config: true
    check_command: hostalive
    check_interval: 90s
    check_timeout: 60
    command_endpoint: fooendpoint
    disabled: false
    display_name: foohosttemplate
    enable_active_checks: true
    enable_event_handler: false
    enable_flapping: false
    enable_notifications: true
    enable_passive_checks: false
    enable_perfdata: false
    flapping_threshold_high: "30.0"
    flapping_threshold_low: "25.0"
    has_agent: true
    icon_image_alt: "alt text"
    icon_image: "http://url1"
    master_should_connect: true
    max_check_attempts: 3
    object_name: foohosttemplate
    retry_interval: "1m"
    volatile: false
    groups:
      - "foohostgroup"
    imports:
      - ''
    vars:
      dnscheck: "no"

- name: Update host template
  telekom_mms.icinga_director.icinga_host_template:
    state: present
    url: "{{ icinga_url }}"
    url_username: "{{ icinga_user }}"
    url_password: "{{ icinga_pass }}"
    object_name: foohosttemplate
    notes: "example note"
    notes_url: "'http://url1' 'http://url2'"
    append: true

作者

  • Michaela Mattes (@michaelamattes)