Open mths0x5f opened 7 years ago
I think the zabbix::template defined type is for when end servers declare templates that the zabbix server collects via puppet db. Something like that anyway!!
It looks like you'd probably have more success if you used the zabbix_template native type directly instead.
As far as I know, loading custom templates doesn't require a puppetdb. Assigning them to hosts does.
I use roles and profiles and in my profile I have this:
class profile::zabbix::full_server (
String $version = 'present',
Boolean $configure_firewall_rules = true,
Boolean $manage_repo = false,
String $zabbix_url = $::facts['networking']['fqdn'],
Boolean $apply_api34_patch = false,
Optional[Hash[String, Struct[{templ_source => String[1]}]]] $templates = undef
){
class { '::zabbix':
javagateway => $::profile::zabbix::javagateway::listenip,
manage_firewall => $configure_firewall_rules,
zabbix_url => $zabbix_url,
manage_repo => $manage_repo,
}
if $configure_firewall_rules {
firewall { '200 Zabbix web access':
chain => $::input_chain_name,
proto => 'tcp',
action => 'accept',
dport => [ 80, 443 ],
}
}
#not all selinux is managed by the Zabbix module
if $::facts['selinux'] == true {
selboolean{[ 'httpd_can_network_connect', 'httpd_can_network_connect_db' ]:
persistent => true,
value => 'on',
}
}
if $::zabbix::manage_resources and $apply_api34_patch {
file_line { 'Apply zabbixapi patch for 3.4':
path => '/opt/puppetlabs/puppet/lib/ruby/gems/2.1.0/gems/zabbixapi-3.2.1/lib/zabbixapi/client.rb',
line => ' unless api_version =~ /(2\.4|3\.[024])\.\d+/',
match => ' unless api_version',
}
}
if $templates {
create_resources('::zabbix::template', $templates)
}
}
I created a custom module called zabbix_templates_generic in which I only have a files folder with all the templates.
And in my hiera i define them like this:
profile::zabbix::full_server::templates:
'C_Template App Zabbix Server':
templ_source: 'puppet:///modules/zabbix_templates_generic/C_Template App Zabbix Server.xml'
'C_Template OS Linux':
templ_source: 'puppet:///modules/zabbix_templates_generic/C_Template OS Linux.xml'
How this
zabbix::template
works? I'm testing this module for installing 3 nodes. But when I try to import a template to Zabbix, it just copies the template to/etc/zabbix/imported_templates
on the node; it doesn't import to Zabbix, as I can't see the template on Web interface.