Skip to content

collecting items via snmp does not happen #21

@rogeriojlle

Description

@rogeriojlle
SUMMARY

collecting items via snmp does not happen

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible.snmp.v2c

ANSIBLE VERSION
ansible [core 2.15.10]
  config file = /var/local/meteor/ansible/ansible.cfg
  configured module search path = ['/var/local/meteor/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/ansible
  ansible collection location = /var/local/meteor/.ansible/collections:/usr/share/ansible/collections
  executable location = /var/local/meteor/ansible/.venv/bin/ansible
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2.1.0.1)] (/var/local/meteor/ansible/.venv/bin/python)
  jinja version = 3.1.3
  libyaml = True

COLLECTION VERSION
# /var/local/meteor/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 8.5.0

# /var/local/meteor/ansible/.venv/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.5.2

# /var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.5.2

CONFIGURATION
CONFIG_FILE() = /var/local/meteor/ansible/ansible.cfg
DEPRECATION_WARNINGS(/var/local/meteor/ansible/ansible.cfg) = True
DISPLAY_SKIPPED_HOSTS(/var/local/meteor/ansible/ansible.cfg) = True
HOST_KEY_CHECKING(/var/local/meteor/ansible/ansible.cfg) = False

OS / ENVIRONMENT

NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"

ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3

STEPS TO REPRODUCE

run a playbook with the website example

inventario.ini:
192.168.25.1

[all:vars]
ansible_python_interpreter = /var/local/meteor/ansible/.venv/bin/python
ansible_connection = ansible.snmp.v2c
ansible_snmp_community = by7


tarefa.yaml
- name: Test site playbook for ansible.snmp
  hosts: all
  gather_facts: false
  tasks:
    - name: Retreive several individual OIDs
      ansible.snmp.get:
        oids:
          - oid: "SNMPv2-MIB::sysDescr"
            iid: "0"
        numeric: false
        long_names: true
EXPECTED RESULTS
ACTUAL RESULTS

apparently he can't find the hostname
ansible]$ ansible-playbook -vvv -i inventario.ini tarefa.yaml

ansible-playbook [core 2.15.10]
  config file = /var/local/meteor/ansible/ansible.cfg
  configured module search path = ['/var/local/meteor/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/ansible
  ansible collection location = /var/local/meteor/.ansible/collections:/usr/share/ansible/collections
  executable location = /var/local/meteor/ansible/.venv/bin/ansible-playbook
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2.1.0.1)] (/var/local/meteor/ansible/.venv/bin/python)
  jinja version = 3.1.3
  libyaml = True
Using /var/local/meteor/ansible/ansible.cfg as config file
host_list declined parsing /var/local/meteor/ansible/inventario.ini as it did not pass its verify_file() method
script declined parsing /var/local/meteor/ansible/inventario.ini as it did not pass its verify_file() method
auto declined parsing /var/local/meteor/ansible/inventario.ini as it did not pass its verify_file() method
yaml declined parsing /var/local/meteor/ansible/inventario.ini as it did not pass its verify_file() method
Parsed /var/local/meteor/ansible/inventario.ini inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: tarefa.yaml **********************************************************************************
1 plays in tarefa.yaml

PLAY [Test site playbook for ansible.snmp] *************************************************************

TASK [Retreive several individual OIDs] ****************************************************************
task path: /var/local/meteor/ansible/tarefa.yaml:5
[WARNING]: The "ansible.snmp.v2c" connection plugin has an improperly configured remote target value,
forcing "inventory_hostname" templated value instead of the string
ESTABLISHED SNMP v2 CONNECTION: 192.168.25.1
Exception ignored in: <function Session.__del__ at 0x7f1af9d593a0>
Traceback (most recent call last):
  File "/var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/netsnmp/client.py", line 223, in __del__
    res = client_intf.delete_session(self)
SystemError: <built-in function delete_session> returned a result with an error set
The full traceback is:
Traceback (most recent call last):
  File "/var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/ansible/executor/task_executor.py", line 165, in run
    res = self._execute()
  File "/var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/ansible/executor/task_executor.py", line 656, in _execute
    result = self._handler.run(task_vars=vars_copy)
  File "/var/local/meteor/.ansible/collections/ansible_collections/ansible/snmp/plugins/action/get.py", line 55, in run
    response = self._connection.get()
  File "/var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/ansible/plugins/connection/__init__.py", line 35, in wrapped
    self._connect()
  File "/var/local/meteor/.ansible/collections/ansible_collections/ansible/snmp/plugins/connection/v2c.py", line 121, in _connect
    super()._connect()
  File "/var/local/meteor/.ansible/collections/ansible_collections/ansible/snmp/plugins/plugin_utils/snmp_connection_base.py", line 67, in _connect
    self._instance = SnmpInstance(
  File "/var/local/meteor/.ansible/collections/ansible_collections/ansible/snmp/plugins/plugin_utils/netsnmp_instance.py", line 65, in __init__
    self.session = netsnmp.Session(**args)
  File "/var/local/meteor/ansible/.venv/lib64/python3.9/site-packages/netsnmp/client.py", line 198, in __init__
    raise Error(err)
netsnmp.client.Error: Invalid address (inventory_hostname)
fatal: [192.168.25.1]: FAILED! => {
    "msg": "Unexpected failure during module execution: Invalid address (inventory_hostname)",
    "stdout": ""
}

PLAY RECAP *********************************************************************************************
192.168.25.1               : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions