Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from 1n/templates
import templates and create hostgroup if missing
- Loading branch information
Showing
11 changed files
with
230 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'zabbix')) | ||
Puppet::Type.type(:zabbix_template).provide(:ruby, :parent => Puppet::Provider::Zabbix) do | ||
|
||
def create | ||
zabbix_url = @resource[:zabbix_url] | ||
|
||
if zabbix_url != '' | ||
self.class.require_zabbix | ||
end | ||
|
||
# Set some vars | ||
template_name = @resource[:template_name] | ||
template_source = @resource[:template_source] | ||
zabbix_url = @resource[:zabbix_url] | ||
zabbix_user = @resource[:zabbix_user] | ||
zabbix_pass = @resource[:zabbix_pass] | ||
apache_use_ssl = @resource[:apache_use_ssl] | ||
|
||
# Connect to zabbix api | ||
zbx = self.class.create_connection(zabbix_url,zabbix_user,zabbix_pass,apache_use_ssl) | ||
|
||
zbx.configurations.import( | ||
:format => "xml", | ||
:rules => { | ||
:applications => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:discoveryRules => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:graphs =>{ | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:groups => { | ||
:createMissing => true | ||
}, | ||
:image => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:items => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:maps => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:screens => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:templateLinkage => { | ||
:createMissing => true | ||
}, | ||
:templates => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:templateScreens => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
}, | ||
:triggers => { | ||
:createMissing => true, | ||
:updateExisting => true | ||
} | ||
}, | ||
:source => template_source | ||
) | ||
end | ||
|
||
def exists? | ||
zabbix_url = @resource[:zabbix_url] | ||
|
||
if zabbix_url != '' | ||
self.class.require_zabbix | ||
end | ||
|
||
template_name = @resource[:template_name] | ||
template_source = @resource[:template_source] | ||
zabbix_user = @resource[:zabbix_user] | ||
zabbix_pass = @resource[:zabbix_pass] | ||
apache_use_ssl = @resource[:apache_use_ssl] | ||
|
||
zbx = self.class.create_connection(zabbix_url,zabbix_user,zabbix_pass,apache_use_ssl) | ||
self.class.check_template_is_equal(template_name,template_source,zabbix_url,zabbix_user,zabbix_pass,apache_use_ssl) | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Puppet::Type.newtype(:zabbix_template) do | ||
|
||
ensurable do | ||
defaultvalues | ||
defaultto :present | ||
end | ||
|
||
newparam(:template_name, :namevar => true) do | ||
desc 'The name of template.' | ||
end | ||
|
||
newparam(:template_source) do | ||
desc 'Template source file.' | ||
end | ||
|
||
newparam(:zabbix_url) do | ||
desc 'The url on which the zabbix-api is available.' | ||
end | ||
|
||
newparam(:zabbix_user) do | ||
desc 'Zabbix-api username.' | ||
end | ||
|
||
newparam(:zabbix_pass) do | ||
desc 'Zabbix-api password.' | ||
end | ||
|
||
newparam(:apache_use_ssl) do | ||
desc 'If apache is uses with ssl' | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# == Class zabbix::resources::template | ||
# | ||
# This will create an resources into puppetdb | ||
# for automatically configuring agent into | ||
# zabbix front-end. | ||
# | ||
# === Requirements | ||
# | ||
# Nothing. | ||
# | ||
# When manage_resource is set to true, this class | ||
# will be loaded from 'zabbix::template'. So no need | ||
# for loading this class manually. | ||
# | ||
# | ||
define zabbix::resources::template ( | ||
$template_name = $title, | ||
$template_source, | ||
) { | ||
|
||
@@zabbix_template { "${template_name}": | ||
template_source => $template_source, | ||
zabbix_url => '', | ||
zabbix_user => '', | ||
zabbix_pass => '', | ||
apache_use_ssl => '', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define zabbix::template ( | ||
$templ_name = $title, | ||
$templ_source = '', | ||
) { | ||
|
||
zabbix::resources::template { "${templ_name}": | ||
template_name => $templ_name, | ||
template_source => $templ_source, | ||
} | ||
} |