Puppet Class: bacula::config::validate
- Defined in:
- manifests/config/validate.pp
Overview
Class: bacula::config::validate
This class takes parameters which values need to be validated in some way
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 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'manifests/config/validate.pp', line 5
class bacula::config::validate(
$db_backend,
$db_database,
$db_port,
$db_host,
$db_user,
$db_password,
$mail_to,
$is_director,
$is_client,
$is_storage,
$director_password,
$console_password,
$director_server,
$storage_server,
$manage_console,
$manage_bat,
$console_password,
$use_console,
$manage_db,
$manage_db_tables
) {
#Validate our booleans
validate_bool($manage_console)
validate_bool($manage_bat)
validate_bool($is_director)
validate_bool($is_storage)
validate_bool($is_client)
validate_bool($use_console)
validate_bool($manage_db_tables)
validate_bool($manage_db)
if $use_console {
if empty($console_password) {
fail 'console_password cannot be empty'
}
}
#Validate mail_to is an email address
if $is_director {
validate_re($mail_to, '^[\w-]+@([\w-]+\.)+[\w-]+$')
}
#Validate the director and storage servers given are fully qualified domain names
validate_re($director_server, '^[a-z0-9_-]+(\.[a-z0-9_-]+){2,}$')
validate_re($storage_server, '^[a-z0-9_-]+(\.[a-z0-9_-]+){2,}$')
#Validate server values aren't empty
if empty($director_server) {
failse '$director_server cannot be empty'
}
if empty($storage_server) {
fail '$storage_server cannot be empty'
}
#Validate the passwords aren't empty
if $is_director {
if empty($director_password) {
fail '$director_password cannot be empty'
}
}
if $manage_console {
if empty($console_password) {
fail '$console_password cannot be empty'
}
}
if empty($db_database) {
fail '$db_database cannot be empty'
}
if $db_backend != 'sqlite' {
if empty($db_host) {
fail '$db_host cannot be empty'
}
if empty($db_user) {
fail '$db_user cannot be empty'
}
if ! is_integer($db_port) {
fail '$db_port must be a port number'
}
if empty($db_password) {
fail '$db_password cannot be empty'
}
}
}
|