autorole.pp 1.07 KB
Newer Older
Markus Frosch's avatar
Markus Frosch committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class icinga2_testing::roles::autorole
{
  if ! $::icingatest_instance {
    fail('Fact or parameter "icingatest_instance" is not present, hostname may not be conform!')
  }

  if $::icingatest_instance and $::icingatest_role and $::icingatest_hostno {
    notice("Running autorole in instance=${::icingatest_instance} - role=${::icingatest_role} - hostno=${::icingatest_hostno}")

    # check config that has to be present in hiera
    $zones_config = hiera('icinga2::object::zone')
    $repo_version = hiera('icinga2_testing::profiles::repository::version')

    if $::icingatest_role == 'master' {
15
16
      validate_integer($::icingatest_hostno)

Markus Frosch's avatar
Markus Frosch committed
17
      include ::icinga2_testing::roles::master
18
      if $::icingatest_hostno == '1' or $::icingatest_hostno == 1 {
Markus Frosch's avatar
Markus Frosch committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        include ::icinga2_testing::roles::master_config
      }
    }
    elsif $::icingatest_role == 'satellite' {
      include ::icinga2_testing::roles::satellite
    }
    else {
      fail("Unsupported role '${::icingatest_role}'!")
    }
  }
  else {
    fail("Could not identify host '${::fqdn}' by facts or parameters!")
  }
}