Open xenadmin opened 4 years ago
@hatifnatt: @myii pinged me, if I'm available for lifting the formula to 5.0. That reminded me of this open PR and I wanted to ask you for your opinion? That would help me catch up with my fork, so I could come back for improving.
@hatifnatt I've been discussing some stuff about the formula with @xenadmin and we realised that this PR was still outstanding. Would you mind having a look and merging if all is OK? It's a relatively small change, so should be easy enough to review.
Whoops, both at the same time!
It's a good change for sure, but module run
used for restart of Zabbix agent for a reason see #77
I can suggest to use it to preform restart after package changes too, like this:
zabbix-agent:
pkg.installed:
- pkgs:
{%- for name in zabbix.agent.pkgs %}
- {{ name }}{% if zabbix.agent.version is defined and 'zabbix' in name %}: '{{ zabbix.agent.version }}'{% endif %}
{%- endfor %}
{% if salt['grains.get']('os') != 'Windows' %}
- require_in:
- user: zabbix-formula_zabbix_user
- group: zabbix-formula_zabbix_group
{% endif %}
- watch_in:
- module: zabbix-agent-restart
service.running:
- name: {{ zabbix.agent.service }}
- enable: True
- require:
- pkg: zabbix-agent
- file: zabbix-agent-logdir
{% if salt['grains.get']('os') != 'Windows' %}
- file: zabbix-agent-piddir
{% endif %}
zabbix-agent-restart:
module.wait:
- name: service.restart
- m_name: {{ zabbix.agent.service }}
Things to notice:
zabbix-agent:
pkg.installed:
...
- watch_in:
- module: zabbix-agent-restart
instead of
zabbix-agent:
service.running:
...
- watch:
- pkg: zabbix-agent
I started playing around with forced version updates, and noticed that even if the packages install successfully, the service doesn't notice it. This PR could fix that.
Example:
/srv/pillar/zabbix/init.sls