autorole.pp 1.12 KB
Newer Older
Markus Frosch's avatar
Markus Frosch committed
1
2
3
4
5
6
7
8
9
10
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
Markus Frosch's avatar
Markus Frosch committed
11
12
13
14
    # actual values are unused
    hiera('icinga2::feature::api::endpoints')
    hiera('icinga2::feature::api::zones')
    hiera('icinga2_testing::profiles::repository::version')
Markus Frosch's avatar
Markus Frosch committed
15
16

    if $::icingatest_role == 'master' {
17
18
      validate_integer($::icingatest_hostno)

Markus Frosch's avatar
Markus Frosch committed
19
      include ::icinga2_testing::roles::master
20
      if $::icingatest_hostno == '1' or $::icingatest_hostno == 1 {
Markus Frosch's avatar
Markus Frosch committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        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!")
  }
}