Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Allow appending instead of replacing zabbix templates #60434

Open
colttt opened this issue Jun 24, 2021 · 7 comments
Open

[FEATURE REQUEST] Allow appending instead of replacing zabbix templates #60434

colttt opened this issue Jun 24, 2021 · 7 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Milestone

Comments

@colttt
Copy link

colttt commented Jun 24, 2021

Is your feature request related to a problem? Please describe.
It would be very nice if we can add the possibility to just add a new template to zabbix in the module states.zabbix_host. Currently, it is not possible to just add a new template, I must call all templates.

Describe the solution you'd like
We've a state that install the zabbix-agent and create this host in zabbix and add a template (mostly the Linux-Template) and if this server also have additional services like apache, we call also the apache-install-state which also add the Zabbix-Template "App Apache", but instead of using just assign the new template like:

apache_template_to_host:
  zabbix_host.assign_templates:
    - host: {{ grains['host'] }}
    - templates:
      - "Template App Apache by Zabbix agent"

we must call all templates that we want:

apache_template_to_host:
  zabbix_host.assign_templates:
    - host: {{ grains['host'] }}
    - templates:
      - "Template App Apache by Zabbix agent"
      - "Template OS Linux"

the state could be called the current templates and in the second call it could be add the current templates + new templates

@colttt colttt added Feature new functionality including changes to functionality and code refactors, etc. needs-triage labels Jun 24, 2021
@OrangeDog
Copy link
Contributor

Can you edit the title to e.g. [FEATURE REQUEST] Allow appending instead of replacing zabbix templates

In the meantime, you can build the list of templates with jinja and set them with a single state.
It could be done with merged/aggregate pillar data or map.jinja.

I'm not sure if there's a way to accumulate values from other states to be used in this state.
Perhaps something with slots.

@colttt colttt changed the title [FEATURE REQUEST] [FEATURE REQUEST] Allow appending instead of replacing zabbix templates Jun 24, 2021
@colttt
Copy link
Author

colttt commented Jun 24, 2021

I'm not sure if there's a way to accumulate values from other states to be used in this state.

It's not need, it's "just" need more logic, we can check via API what of templates are already assigned and if it missing just add this

I'm not sure if there's a way to accumulate values from other states to be used in this state.

OK but then I should check if it somehow defined in the top.sls, etc.. I prefer the logic per state ;-)

@OrangeDog
Copy link
Contributor

However, with this feature either you can't easily remove unused templates, or you'd be removing and re-adding every run.

@OrangeDog
Copy link
Contributor

we can check via API what of templates are already assigned

No, I meant a way for the apache state to add to a list that the zabbix state can then use to set all the templates as now.

@OrangeDog
Copy link
Contributor

OrangeDog commented Jun 24, 2021

It looks like there is a way. The list could be stored via data or the cache, and retrieved with a slot.

@sagetherage sagetherage added this to the Approved milestone Jun 24, 2021
@reedacus25
Copy link

I don't have much to add to this, other than that I too would love to see states.zabbix_host.assign_templates change from a "clean inventory" method to an "append" method.

I only mention clean inventory specifically, because that is how states.zabbix_host.present works, with the inventory_clean option.

inventory_clean -- Optional - Boolean value that selects if the current inventory will be cleaned and overwritten by the declared inventory list (True); or if the inventory will be kept and only updated with inventory list contents (False). Defaults to True

I think that if states.zabbix_host.assign_templates were able to have the inventory_clean option added, that it would be able to maintain current functionality, as well as add the append functionality to those that want it, myself being one of those.

Ie I have a zabbix-agent state that installs and configures the agent and adds the host and assigns "base level" templates, but then I have other states that come along after and configure different applications based on other conditions, and what I would ideally like is for the application states to be able to handle setting up the monitoring for themselves at the same time as the application bootstrap.

I know its not a PR, but I figured that keeping the discussion alive and giving it direction might be useful.

@OrangeDog
Copy link
Contributor

@nicolas-janzen that's a completely different system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc.
Projects
None yet
Development

No branches or pull requests

4 participants