salt icon indicating copy to clipboard operation
salt copied to clipboard

zabbix_host module does not process additional host properties

Open slivik opened this issue 7 years ago • 11 comments

Description of Issue

I try to create a new Zabbix host with saltstack. The description of Zabbix_host.present stated this: This function accepts all standard host properties: keyword argument names differ depending on your zabbix version, see:https://www.zabbix.com/documentation/2.4/manual/api/reference/host/object#host I have added for example tls keywords to the Zabbix_host.present command in the sls file:

Setup

zabbix_create_host:
  zabbix_host.present:
    - host: {{ salt['grains.get']('nodename') }}
    - groups:
      - 20
    - interfaces:
        - default:
            - ip: '0.0.0.0'
            - dns: ''
            - type: 'agent'
            - port: '10050'
    - inventory_mode: 1
    - tls_connect: 2
    - tls_accept: 2
    - tls_psk_identity: PSK_{{ salt['grains.get']('nodename') }}
    - tls_psk: {{ salt['pillar.get']('zabbix:psk') }}

Steps to Reproduce Issue

minion log file:

data: {"jsonrpc": "2.0", "params": {"interfaces": [{"ip": "0.0.0.0", "useip": "1", "dns": "", "main": "1", "type": "1", "port": "10050"}], "proxy_hostid": "0", "host": "<hostname>", "groups": [{"groupid": 20}], "inventory": {}}, "id": 0, "auth": "<auth_token>", "method": "host.create"}

Versions Report

All versions affected

slivik avatar Jul 12 '19 13:07 slivik

Thank for letting us know

cmcmarrow avatar Jul 12 '19 14:07 cmcmarrow

I've looked at the code and it ignores all properties other than host, groups, interfaces, inventory, and proxy_host. Even the documented visible_name is ignored.

As well as encryption settings, this also locks out inventory_mode and description.

Also missing, not directly related to this API but logically part of a host, is the ability to configure host macros.

OrangeDog avatar Oct 18 '19 16:10 OrangeDog

It ignores nothing. It is only preprocessing of all parameters to form them properly (pop them out of the dictionary) for next run of the state module and for passing them properly to zabbix execution module. If this is an issue could you, please, send some output?

slivik avatar Nov 07 '19 15:11 slivik

@slivik it's trivial to demonstrate that they're ignored. Here's one example: If the host doesn't exist it will be created, but the name not set. If it already exists, then the name will not be changed,

test zabbix_host:
  zabbix_host.present:
    - host: {{ grains['id'] }}
    - visible_name: 'test'

Show me in the code where kwargs is passed to the execution module.

OrangeDog avatar Nov 07 '19 17:11 OrangeDog

@slivik I'm confused why you're claiming it ignores nothing, when you're the one who raised this issue in the first place.

OrangeDog avatar Nov 07 '19 17:11 OrangeDog

@OrangeDog You describe the situation before I introduced this fix. The line 71 of the fixed code does exactly what you are expecting, i.e. assigns the kwargs to connection_args which is then passed to every call of Zabbix execution module. So if there is any Zabbix host object parameter present then it is passed to the execution module.

slivik avatar Nov 08 '19 09:11 slivik

@slivik Oh, when I said I looked at the code I wasn't talking about your PR.

OrangeDog avatar Nov 08 '19 10:11 OrangeDog

@OrangeDog Sorry for confusion. I thought I was writing to the PR thread.

slivik avatar Nov 08 '19 10:11 slivik

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jan 07 '20 15:01 stale[bot]

This (high severity) issue still exists

OrangeDog avatar Jan 07 '20 17:01 OrangeDog

Thank you for updating this issue. It is no longer marked as stale.

stale[bot] avatar Jan 07 '20 17:01 stale[bot]