Skip to content

Commit

Permalink
Merge branch 'enhancement/add-rspec-tests-for-function-attributes-486…
Browse files Browse the repository at this point in the history
…' into v2.x
  • Loading branch information
lbetz committed Oct 2, 2018
2 parents c43a1b0 + dbcbc61 commit 030ea17
Show file tree
Hide file tree
Showing 78 changed files with 2,260 additions and 5,803 deletions.
12 changes: 6 additions & 6 deletions examples/init_api.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

include ::icinga2::pki::ca

::icinga2::object::apiuser { 'director':
ensure => present,
password => 'Eih5Weefoo2oa8sh',
permissions => [ "*" ],
target => '/etc/icinga2/conf.d/api-users.conf',
}
#::icinga2::object::apiuser { 'director':
# ensure => present,
# password => 'Eih5Weefoo2oa8sh',
# permissions => [ "*" ],
# target => '/etc/icinga2/conf.d/api-users.conf',
#}

::icinga2::object::apiuser { 'icingaweb2':
ensure => present,
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/icinga2_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Puppet::Parser::Functions
newfunction(:icinga2_attributes, :type => :rvalue) do |args|
raise Puppet::ParseError, 'Must provide at least one argument.' if args.length > 4
raise Puppet::ParseError, 'icinga2_atributes(): Must provide at least one argument.' if args.length > 4 || args.length < 1

if args[1]
indent = args[1]
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_x/icinga2/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def self.attributes(attrs, globals, consts, indent=2)

def self.value_types(value)

if value =~ /^\d+\.?\d*[dhms]?$/ || value =~ /^(true|false|null)$/ || value =~ /^!?(host|service|user)\./ || value =~ /^\{{2}.*\}{2}$/
if value =~ /^-?\d+\.?\d*[dhms]?$/ || value =~ /^(true|false|null)$/ || value =~ /^!?(host|service|user)\./ || value =~ /^\{{2}.*\}{2}$/
result = value
else
if $constants.index { |x| if $hash_attrs.include?(x) then value =~ /^!?(#{x})(\..+$|$)/ else value =~ /^!?#{x}$/ end }
Expand Down
5 changes: 4 additions & 1 deletion manifests/feature/api.pp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@
class icinga2::feature::api(
Enum['absent', 'present'] $ensure = present,
Enum['ca', 'icinga2', 'none', 'puppet'] $pki = 'puppet',
Optional[Stdlib::Absolutepath] $ssl_key_path = undef,
Optional[Stdlib::Absolutepath] $ssl_cert_path = undef,
Optional[Stdlib::Absolutepath] $ssl_cacert_path = undef,
Optional[Stdlib::Absolutepath] $ssl_crl_path = undef,
Optional[Boolean] $accept_config = undef,
Optional[Boolean] $accept_commands = undef,
Expand Down Expand Up @@ -343,7 +346,7 @@
order => 10,
notify => $_notify,
}

# manage feature
icinga2::feature { 'api':
ensure => $ensure,
Expand Down
4 changes: 2 additions & 2 deletions manifests/feature/idomysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@
exec { 'idomysql-import-schema':
user => 'root',
path => $::path,
command => "mysql -h '${host}' -P '${port}' -u '${user}' -p'${password}' '${database}' < '${ido_mysql_schema_dir}/mysql.sql'",
unless => "mysql -h '${host}' -P '${port}' -u '${user}' -p'${password}' '${database}' -Ns -e 'select version from icinga_dbversion'",
command => "mysql -h ${host} -P ${port} -u ${user} -p'${password}' ${database} < ${ido_mysql_schema_dir}/mysql.sql",
unless => "mysql -h ${host} -P ${port} -u ${user} -p'${password}' ${database} -Ns -e 'select version from icinga_dbversion'",
}
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/feature/influxdb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
$service_template = { measurement => $service_measurement, tags => $service_tags}

if $enable_ssl {

# Set defaults for certificate stuff
if $ssl_key_path {
$_ssl_key_path = $ssl_key_path }
Expand Down
4 changes: 2 additions & 2 deletions manifests/feature/statusdata.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class icinga2::feature::statusdata(
Enum['absent', 'present'] $ensure = present,
Optional[Stdlib::Absolutepath] $status_path = undef,
Optiona[Stdlib::Absolutepath] $objects_path = undef,
Optiona[Pattern[/^\d+[ms]*$/]] $update_interval = undef,
Optional[Stdlib::Absolutepath] $objects_path = undef,
Optional[Pattern[/^\d+[ms]*$/]] $update_interval = undef,
) {

if ! defined(Class['::icinga2']) {
Expand Down
5 changes: 2 additions & 3 deletions manifests/object/apiuser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# ::icinga2::object::apiuser { 'director':
# ensure => present,
# password => 'Eih5Weefoo2oa8sh',
# permissions => [ "*" ],
# permissions => [ '*' ],
# target => '/etc/icinga2/conf.d/api-users.conf',
# }
#
Expand Down Expand Up @@ -62,9 +62,9 @@
#
define icinga2::object::apiuser(
Stdlib::Absolutepath $target,
Array $permissions,
Enum['absent', 'present'] $ensure = present,
String $apiuser_name = $title,
Optional[Array] $permissions = undef,
Optional[String] $password = undef,
Optional[String] $client_cn = undef,
Variant[String, Integer] $order = 30,
Expand All @@ -86,6 +86,5 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}
}
1 change: 0 additions & 1 deletion manifests/object/checkcommand.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,5 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}
}
1 change: 0 additions & 1 deletion manifests/object/checkresultreader.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}

# import library
Expand Down
1 change: 0 additions & 1 deletion manifests/object/compatlogger.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}

# import library
Expand Down
1 change: 0 additions & 1 deletion manifests/object/dependency.pp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
ignore => $ignore,
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}

}
1 change: 0 additions & 1 deletion manifests/object/endpoint.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@
attrs_list => keys($attrs),
target => $_target,
order => $order,
notify => Class['::icinga2::service'],
}
}
1 change: 0 additions & 1 deletion manifests/object/eventcommand.pp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,5 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}
}
1 change: 0 additions & 1 deletion manifests/object/host.pp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,5 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}
}
1 change: 0 additions & 1 deletion manifests/object/hostgroup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,5 @@
ignore => $ignore,
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}
}
1 change: 0 additions & 1 deletion manifests/object/notification.pp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
apply_target => $apply_target,
assign => $assign,
ignore => $ignore,
notify => Class['::icinga2::service'],
}

}
1 change: 0 additions & 1 deletion manifests/object/notificationcommand.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}

}
1 change: 0 additions & 1 deletion manifests/object/scheduleddowntime.pp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
ignore => $ignore,
target => $target,
order => $order,
notify => Class['::icinga2::service'],
}

}
29 changes: 14 additions & 15 deletions manifests/object/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
#
# ::icinga2::object::service { 'linux_disks':
# import => ['generic-service'],
# apply => 'disk_name =>config in host.vars.disks',
# apply => 'disk_name => config in host.vars.disks',
# check_command => 'disk',
# command_endpoint => 'host.name',
# vars => 'vars + config',
Expand Down Expand Up @@ -228,19 +228,18 @@

# create object
icinga2::object { "icinga2::object::Service::${title}":
ensure => $ensure,
object_name => $service_name,
object_type => 'Service',
import => $import,
apply => $apply,
prefix => $prefix,
assign => $assign,
ignore => $ignore,
template => $template,
attrs => delete_undef_values($attrs),
attrs_list => keys($attrs),
target => $target,
order => $order,
notify => Class['::icinga2::service'],
ensure => $ensure,
object_name => $service_name,
object_type => 'Service',
import => $import,
apply => $apply,
prefix => $prefix,
assign => $assign,
ignore => $ignore,
template => $template,
attrs => delete_undef_values($attrs),
attrs_list => keys($attrs),
target => $target,
order => $order,
}
}
Loading

0 comments on commit 030ea17

Please sign in to comment.