community.vmware.vmware_host_snmp 模块 – 配置 ESXi 主机系统的 SNMP
注意
此模块是 community.vmware 集合 (版本 5.2.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.vmware。
要在 playbook 中使用它,请指定:community.vmware.vmware_host_snmp。
概要
- 此模块可用于配置 ESXi 主机上的嵌入式 SNMP 代理。 
参数
| 参数 | 注释 | 
|---|---|
| SNMP 社区字符串列表。 默认值:  | |
| 用于管理 SNMP 代理的 ESXi 主机名列表。 如果未设置  | |
| vSphere vCenter 或 ESXi 服务器的主机名或 IP 地址。 如果任务中未指定此值,则将使用环境变量  | |
| 来自 IPMI 传感器或 CIM 指示的源硬件事件。 嵌入式 SNMP 代理从 IPMI 传感器  选项 
 | |
| Syslog 日志记录级别。 选项 
 | |
| vSphere vCenter 或 ESXi 服务器的密码。 如果任务中未指定此值,则将使用环境变量  | |
| 将接收所有 HTTPS 请求并转发它们的 HTTP 代理的端口。 如果任务中未指定此值,则将使用环境变量  | |
| 发送测试陷阱以验证配置。 选项 
 | |
| SNMP 代理使用的端口。 默认值:  | |
| 启用、禁用或重置 SNMP 代理。 选项 
 | |
| 管理系统的系统联系人。 | |
| 系统位置。 | |
| 代理不发送的陷阱 OID 列表,例如 [ 1.3.6.1.4.1.6876.4.1.1.0, 1.3.6.1.4.1.6876.4.1.1.1 ] 使用值  | |
| 陷阱目标列表。 您需要为每个陷阱目标使用  默认值:  | |
| vSphere vCenter 或 ESXi 服务器的用户名。 如果任务中未指定此值,则将使用环境变量 | |
| 允许在 SSL 证书无效时连接。当证书不受信任时,将其设置为 如果任务中未指定此值,则将使用环境变量 选项 
 | 
备注
注意
- 如果要清除所有社区字符串、陷阱目标或过滤器,则需要重置代理(恢复出厂设置)。 
- SNMP v3 配置尚未实现。 
- 所有模块都需要 API 写入权限,因此在免费 ESXi 许可证上不支持。 
- 所有变量和 VMware 对象名称都区分大小写。 
示例
- name: Enable and configure SNMP community on standalone ESXi host
  community.vmware.vmware_host_snmp:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    community: [ test ]
    state: enabled
  delegate_to: localhost
- name: Configure SNMP traps and filters on cluster
  community.vmware.vmware_host_snmp:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    cluster_name: '{{ cluster_name }}'
    community: [ test ]
    trap_targets:
      - hostname: 192.168.1.100
        port: 162
        community: test123
      - hostname: 192.168.1.101
        port: 162
        community: test1234
    trap_filter:
      - 1.3.6.1.4.1.6876.4.1.1.0
      - 1.3.6.1.4.1.6876.4.1.1.1
    state: enabled
  delegate_to: localhost
- name: Enable and configure SNMP system contact and location on simple ESXi host in vCenter
  community.vmware.vmware_host_snmp:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    esxi_hostname: '{{ esxi_hostname }}'
    sys_contact: "[email protected]"
    sys_location: "Austin, USA"
    state: enabled
  delegate_to: localhost
- name: Disable SNMP on standalone ESXi host
  community.vmware.vmware_host_snmp:
    hostname: '{{ esxi_hostname }}'
    username: '{{ esxi_username }}'
    password: '{{ esxi_password }}'
    state: disabled
  delegate_to: localhost
返回值
常见的返回值已在此处记录,以下是此模块特有的字段。
| 键 | 描述 | 
|---|---|
| 有关主机系统 SNMP 配置的元数据。 返回:始终 示例:  | 
