summaryrefslogtreecommitdiff
path: root/puppet/modules/site_nagios/manifests/add_host.pp
blob: 5148048d2a8dc63e0617eec1ef4b0aa42f19bd5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
define site_nagios::add_host ($ip, $services='' ) {

  $nagios_hostname = $name

  #notice ("$nagios_hostname $ip $services")

  nagios_host { $nagios_hostname:
    address => $ip,
    use     => 'generic-host',
  }

  # turn serice array into hash
  # https://github.com/ashak/puppet-resource-looping
  $nagios_service_hashpart = {
    'host' => $nagios_hostname,
    'ip'   => $ip,
  }
  $dynamic_parameters = {
    'service' => '%s'
  }

  #$nagios_services = ['one', 'two']
  $nagios_servicename = "${nagios_hostname}_%s"

  $nagios_service_hash = create_resources_hash_from($nagios_servicename, $services, $nagios_service_hashpart, $dynamic_parameters)
  #notice ($created_resource_hash)


  create_resources ( site_nagios::add_service, $nagios_service_hash )
}