-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathvalidate_architecture.pp
80 lines (77 loc) · 2.32 KB
/
validate_architecture.pp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function peadm::validate_architecture (
TargetSpec $master_host,
Variant[TargetSpec, Undef] $master_replica_host = undef,
Variant[TargetSpec, Undef] $puppetdb_database_host = undef,
Variant[TargetSpec, Undef] $puppetdb_database_replica_host = undef,
Variant[TargetSpec, Undef] $compiler_hosts = undef,
) >> Hash {
$result = case [
!!($master_host),
!!($master_replica_host),
!!($puppetdb_database_host),
!!($puppetdb_database_replica_host),
] {
[true, false, false, false]: { # Standard or Large, no HA
({ 'high-availability' => false, 'architecture' => $compiler_hosts ? {
undef => 'standard',
default => 'large',
}})
}
[true, true, false, false]: { # Standard or Large, HA
({ 'high-availability' => false, 'architecture' => $compiler_hosts ? {
undef => 'standard',
default => 'large',
}})
}
[true, false, true, false]: { # Extra Large, no HA
({ 'high-availability' => false, 'architecture' => 'extra-large' })
}
[true, true, true, true]: { # Extra Large, HA
({ 'high-availability' => true, 'architecture' => 'extra-large' })
}
default: { # Invalid
out::message(inline_epp(@(HEREDOC)))
Invalid architecture! Recieved:
- master
<% if $master_replica_host { -%>
- master-replica
<% } -%>
<% if $puppetdb_database_host { -%>
- pdb-database
<% } -%>
<% if $puppetdb_database_replica_host { -%>
- pdb-database-replica
<% } -%>
<% if $compiler_hosts { -%>
- compilers
<% } -%>
Supported architectures include:
Standard
- master
Standard with HA
- master
- master-replica
Large
- master
- compilers
Large with HA
- master
- master-replica
- compilers
Extra Large
- master
- pdb-database
- compilers (optional)
Extra Large with HA
- master
- master-replica
- pdb-database
- pdb-database-replica
- compilers (optional)
| HEREDOC
fail('Invalid architecture!')
}
}
# Return value
$result
}