voxpupuli / puppet-zabbix

Puppet module for creating and maintaining zabbix components with puppet.
https://forge.puppet.com/puppet/zabbix
Apache License 2.0
80 stars 228 forks source link

Added ability to keep templates in sync (no manual changes) #803

Closed Fabian1976 closed 2 years ago

Fabian1976 commented 2 years ago

Pull Request (PR) description

Added some stuff to make the template import the same as importing from the GUI. I hope you merge it.

root-expert commented 2 years ago

Hello @Fabian1976 and thanks for the PR! Can you take a look at the failing spec?

Seems the new parameters are not being passed correctly resulting into null values. I didn't see anything obvious from a quick look.

Fabian1976 commented 2 years ago

Yes, i will have a look. I also can't see what is wrong. I set default values in the template classes, but they seem to be ignored. I didn't ran into any issues when i was locally testing. Will try to troubleshoot it.

Fabian1976 commented 2 years ago

I think i found why i didn't see this error. I'm using the roles and profiles approach from puppet. In short, i have this in my hiera:

profile::zabbix::full_server::templates:
  'Template Active Directory':
    templ_source: 'puppet:///modules/zabbix_templates_generic/Template Active Directory.xml'

And the shortened code in that profile looks like this:

class profile::zabbix::full_server (
  Optional[Hash] $templates = undef,
){
  if $templates {
    case $zabbix::zabbix_version {
      /^5\.[^0]/: {
        $_defaults = {
          'zabbix_version' => $zabbix::zabbix_version,
        }
      }
      default: {
        $_defaults = {}
      }
    }

    create_resources('::zabbix::template', $templates, $_defaults)
  }
}

So i use the create_resources method in combination with the class zabbix::template (which has default values defined). And the tests use the custom type zabbix_template directly (which doesn't have default values defined).

I will add default values to the zabbix_template type and check the tests again.

root-expert commented 2 years ago

Considering squashing your commits once ready 😄

Fabian1976 commented 2 years ago

Ok, squashed commits and pushed