community.vmware.vmware_host_snmp (4.2.0) — module

Configures SNMP on an ESXi host system

Authors: Christian Kotte (@ckotte), Alexander Nikitin (@ihumster)

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

This module can be used to configure the embedded SNMP agent on an ESXi host.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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: "admin@testemail.com"
    sys_location: "Austin, USA"
    state: enabled
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
port:
    default: 443
    description:
    - The port number of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PORT)
      will be used instead.
    type: int

state:
    choices:
    - disabled
    - enabled
    - reset
    default: disabled
    description:
    - Enable, disable, or reset the SNMP agent.
    type: str

hostname:
    description:
    - The hostname or IP address of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_HOST)
      will be used instead.
    type: str

password:
    aliases:
    - pass
    - pwd
    description:
    - The password of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PASSWORD)
      will be used instead.
    type: str

username:
    aliases:
    - admin
    - user
    description:
    - The username of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_USER)
      will be used instead.
    type: str

community:
    default: []
    description:
    - List of SNMP community strings.
    elements: str
    type: list

hw_source:
    choices:
    - indications
    - sensors
    default: indications
    description:
    - Source hardware events from IPMI sensors or CIM Indications.
    - The embedded SNMP agent receives hardware events either from IPMI sensors V(sensors)
      or CIM indications V(indications).
    type: str

log_level:
    choices:
    - debug
    - info
    - warning
    - error
    default: info
    description:
    - Syslog logging level.
    type: str

send_trap:
    default: false
    description:
    - Send a test trap to validate the configuration.
    type: bool

snmp_port:
    default: 161
    description:
    - Port used by the SNMP agent.
    type: int

proxy_host:
    description:
    - Address of a proxy that will receive all HTTPS requests and relay them.
    - The format is a hostname or a IP.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_HOST)
      will be used instead.
    required: false
    type: str

proxy_port:
    description:
    - Port of the HTTP proxy that will receive all HTTPS requests and relay them.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

sys_contact:
    description:
    - System contact who manages the system.
    type: str

trap_filter:
    description:
    - A list of trap oids for traps not to be sent by agent, e.g. [ 1.3.6.1.4.1.6876.4.1.1.0,
      1.3.6.1.4.1.6876.4.1.1.1 ]
    - Use value V(reset) to clear settings.
    elements: str
    type: list

cluster_name:
    description:
    - Name of cluster.
    - All host system from given cluster used to manage SNMP agent.
    - Required parameter, if O(esxi_hostname) is not set.
    type: str
    version_added: 3.11.0
    version_added_collection: community.vmware

sys_location:
    description:
    - System location.
    type: str

trap_targets:
    default: []
    description:
    - A list of trap targets.
    - You need to use C(hostname), C(port), and C(community) for each trap target.
    elements: dict
    type: list

esxi_hostname:
    description:
    - List of ESXi hostname to manage SNMP agent.
    - Required parameter, if O(cluster_name) is not set.
    elements: str
    type: list
    version_added: 3.11.0
    version_added_collection: community.vmware

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to V(false) when certificates
      are not trusted.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS)
      will be used instead.
    type: bool

Outputs

results:
  description: metadata about host system's SNMP configuration
  returned: always
  sample:
    changed: true
    esx01.example.local:
      changed: true
      community:
      - test
      community_previous: []
      hw_source: indications
      log_level: info
      log_level_previous: warning
      msg: SNMP state, community list, log level, sys contact, and sys location changed
      port: 161
      state: enabled
      state_previous: disabled
      sys_contact_previous: ''
      sys_location_previous: ''
      trap_filter: null
      trap_targets: []
    failed: false
  type: dict