47 lines
1.5 KiB
Ruby
47 lines
1.5 KiB
Ruby
#
|
|
# Copyright 2015 Mirantis, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
|
|
Puppet::Type.newtype(:plugin_zabbix_hostgroup) do
|
|
desc <<-EOT
|
|
Manage a host group in Zabbix
|
|
EOT
|
|
|
|
ensurable do
|
|
defaultvalues
|
|
defaultto :present
|
|
end
|
|
|
|
newparam(:name, :namevar => true) do
|
|
desc 'Name of the host group.'
|
|
newvalues(/.+/)
|
|
end
|
|
|
|
newparam(:api) do
|
|
desc 'Zabbix api info: endpoint, username, password.'
|
|
isrequired
|
|
|
|
validate do |value|
|
|
fail("api is not a hash") unless value.kind_of?(Hash)
|
|
fail("api hash does not contain username") unless value.has_key?("username")
|
|
fail("username is not valid") unless value['username'] =~ /.+/
|
|
fail("api hash does not contain password") unless value.has_key?("password")
|
|
fail("password is not valid") unless value['password'] =~ /.+/
|
|
fail("api hash does not contain endpoint") unless value.has_key?("endpoint")
|
|
fail("endpoint is not valid") unless value['endpoint'] =~ /http(s)?:\/\/.+/
|
|
end
|
|
end
|
|
end
|