saltstack-formulas / zabbix-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
50 stars 121 forks source link

Zabbix Server/Proxy/Agent init.sls doesn't honor any pillar values at all. #126

Open xenadmin opened 4 years ago

xenadmin commented 4 years ago

While testing my proposed changes for #125 in possibly encountered a critical bug.

Steps to reproduce Create a pillar for Zabbx Proxy /srv/pillar/zabbix/proxy.sls and write a value for pidfile, logfile, or dbname:

zabbix-proxy:
  pidfile: /tmp/zabbix_proxy.pid

Watch the resultant Pillar values on the minion salt 'zabprox.*' pillar.items they change accordingly:

    zabbix-proxy:
        ----------
        pidfile:
            /tmp/zabbix_proxy.pid

Make a state apply test salt 'zabprox.*' state.apply test=true and watch that the states do not change at all!

  Name: /var/lib/zabbix - Function: file.directory - Result: Clean Started: - 07:28:57.013935 Duration: 0.541 ms

Expected behavior /srv/formulas/zabbix-formula/zabbix/proxy/init.sls has to read in the pillar not only from /srv/formulas/zabbix-formula/zabbix/map.jinja but also from /srv/pillar/zabbix/proxy.sls and change the file.directory states accordingly.

Partly resoltution I believe this bug was introduced by @hatifnatt in commit 2907cda5f6b087a8b3b59346f7a7b6a3d011de8b and @aboe76 in commit cdf5b804579d409c366fa54db847c43f16a5fbb8 for example.

I build an example solution that works very well for me and solves also #125 but I don't believe it's the right solution as it seems much too complicated: /srv/formulas/zabbix-formula/zabbix/proxy/init.sls

{% set logfile = salt['pillar.get']('zabbix-proxy:logfile', zabbix.proxy.logfile) %}
{% set pidfile = salt['pillar.get']('zabbix-proxy:pidfile', zabbix.proxy.pidfile) %}
{% set sqlitedir = salt['pillar.get']('zabbix-proxy:dbname', zabbix.proxy.dname) %}

https://gist.github.com/xenadmin/2c951695d215ab9e59f31184642f6c6c/revisions#diff-39859e34161f0cb6f5f50974282a2593

It can't be the solution, to have a line in the header for each and every folder I have to read in from the pillar, including a fallback to the map.jinja, can it?

I would like to ask for your help so we can solve this together!

hatifnatt commented 4 years ago

If I remember correctly (and according to the example in pillar.example) to override values from map.jinja in state (not in generated config file) you need to set values under zabbix:lookup:proxy i.e.

zabbix:
  lookup:
    proxy:
      pidfile: /tmp/zabbix_proxy.pid

Actually this formula is really clunky and it's require total rewrite mostly from scratch. I point some problems in #79