telekom_mms.icinga_director.icinga_service 模块 – 在 Icinga2 中管理服务

注意

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

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

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

要在剧本中使用它,请指定:telekom_mms.icinga_director.icinga_service

telekom_mms.icinga_director 1.0.0 中的新增功能

概要

  • 通过 director API 添加或删除 Icinga2 服务。

参数

参数

注释

append

布尔值

telekom_mms.icinga_director 1.25.0 中添加

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

注意 - 无法追加到现有的变量、导入或任何其他列表/字典。您必须覆盖整个列表/字典。

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

选项

  • false

  • true

check_command

字符串

检查命令定义。

check_interval

字符串

您的常规检查间隔。

check_period

字符串

确定应何时监控此对象的时间段的名称。默认情况下不限制。

check_timeout

字符串

检查命令超时时间(秒)。覆盖 CheckCommand 的超时属性。

client_cert

路径

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

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

client_key

路径

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

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

disabled

布尔值

禁用的对象将不会部署。

选项

  • false ← (默认)

  • true

display_name

字符串

此服务的替代名称。

enable_active_checks

布尔值

是否主动检查此对象。

选项

  • false

  • true

enable_event_handler

布尔值

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

选项

  • false

  • true

enable_notifications

布尔值

是否为此对象发送通知。

选项

  • false

  • true

enable_passive_checks

布尔值

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

选项

  • false

  • true

enable_perfdata

布尔值

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

选项

  • false

  • true

force

布尔值

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

选项

  • false ← (默认)

  • true

force_basic_auth

布尔值

使用 url_usernameurl_password 指定的凭据应通过 HTTP 标头传递。

选项

  • false ← (默认)

  • true

groups

列表 / 元素=字符串

应直接分配给此服务的服务组。

服务组由于各种原因可能很有用。

它们有助于在 Icinga Web 2 中提供特定于服务类型的视图,无论是用于自定义仪表板还是作为实施限制的工具。

服务组可以直接分配给单个服务或服务模板。

默认值: []

host

字符串

选择应将此单个服务分配到的主机。

当未定义 `service_set` 时,此字段将是必需的。

http_agent

字符串

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

默认值: "ansible-httpget"

imports

列表 / 元素=字符串

可导入的模板,您可以添加任意多个。

请注意,从多个模板导入属性时,顺序很重要 - 最后一个优先。

默认值: []

max_check_attempts

字符串

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

notes

字符串

telekom_mms.icinga_director 1.8.0 中添加

此对象的附加注释。

notes_url

字符串

telekom_mms.icinga_director 1.8.0 中添加

指向此对象的附加注释的 URL。

像这样分隔多个 url “'http://url1' 'http://url2'”。

最大长度为 255 个字符。

object_name

别名:name

字符串 / 必需

服务的名称。

retry_interval

字符串

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

service_set

字符串

telekom_mms.icinga_director 1.29.0 中添加

选择应将此单个服务分配到的服务集名称。

当未定义 `host` 时,此字段将是必需的。

state

字符串

应用功能状态。

选项

  • "present" ← (默认)

  • "absent"

url

字符串 / 必需

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

url_password

字符串

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

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

url_username

字符串

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

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

use_agent

布尔值

此服务的检查命令是否应该在 Icinga 代理上执行。

选项

  • false

  • true

use_gssapi

布尔值

在 ansible-core 2.11 中添加

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

需要安装 Python 库 gssapi

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

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

选项

  • false ← (默认)

  • true

use_proxy

布尔值

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

选项

  • false

  • true ← (默认)

validate_certs

布尔值

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

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

选项

  • false

  • true ← (默认)

vars

字典

服务的自定义属性。

默认值: {}

volatile

布尔值

此检查是否易失。

选项

  • false

  • true

备注

注意

  • 此模块支持检查模式。

示例

- name: Create service
  tags: service
  telekom_mms.icinga_director.icinga_service:
    state: present
    url: "{{ icinga_url }}"
    url_username: "{{ icinga_user }}"
    url_password: "{{ icinga_pass }}"
    object_name: "foo service"
    display_name: "foo service"
    check_command: hostalive
    use_agent: false
    host: foohost
    vars:
      procs_argument: consul
      procs_critical: '1:'
      procs_warning: '1:'

- name: Update service
  tags: service
  telekom_mms.icinga_director.icinga_service:
    state: present
    url: "{{ icinga_url }}"
    url_username: "{{ icinga_user }}"
    url_password: "{{ icinga_pass }}"
    object_name: "foo service"
    display_name: "foo service"
    host: foohost
    notes: "example note"
    notes_url: "'http://url1' 'http://url2'"
    append: true

- name: Create serviceset service
  telekom_mms.icinga_director.icinga_service:
    state: present
    url: "{{ icinga_url }}"
    url_username: "{{ icinga_user }}"
    url_password: "{{ icinga_pass }}"
    object_name: "foo service serviceset"
    service_set: "foo_serviceset"

作者

  • Sebastian Gumprich (@rndmh3ro)