Puppet Class: db2::install
- Defined in:
- manifests/install.pp
Overview
Class db2::install
This class is called from db2 for install.
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'manifests/install.pp', line 6
class db2::install {
validate_legacy(
Optional[String],
'validate_re',
$db2::instance_name,
['^[a-zA-Z0-9]{1,8}$']
)
validate_legacy(
Optional[String],
'validate_re',
$db2::instance_user,
['^[a-zA-Z0-9]{1,8}$'] #CHAR(8) && !/w
)
validate_legacy(
Optional[String],
'validate_re',
$db2::instance_group,
['^[a-zA-Z0-9]{1,30}$'] #CHAR(30) && !/w
)
validate_legacy(
Optional[String],
'validate_re',
$db2::fenced_user,
['^[a-zA-Z0-9]{1,8}$'] #CHAR(8) && !/w
)
validate_legacy(
Optional[String],
'validate_re',
$db2::fenced_group,
['^[a-zA-Z0-9]{1,30}$'] #CHAR(30) && !/w
)
validate_legacy(
Optional[String],
'validate_re',
$db2::installer_source_dir,
['(?<!\/)$'] # Must not end in trailing slash
)
validate_legacy(
Optional[String],
'validate_re',
$db2::installer_target_dir,
['(?<!\/)$'] # Must not end in trailing slash
)
# If we're not in vagrant, then assert that our passwords aren't 'vagrant'.
if $::is_vagrant != 'true' { # lint:ignore:quoted_booleans
validate_legacy(Optional[String], 'validate_re', $db2::instance_user_password, ['^(?!vagrant$).*$'])
validate_legacy(Optional[String], 'validate_re', $db2::fenced_user_password, ['^(?!vagrant$).*$'])
validate_legacy(Optional[String], 'validate_re', $db2::password_salt, ['^(?!vagrant$).*$'])
# TODO: installer_source_dir != *vagrant*
}
# Notes: https://bernhard.hensler.net/ibm-db2-install-uninstall-update/
# TODO: (Long-term) Break instances to def at profile::db2::instance.
# Groups
group{$db2::instance_group:
gid => $db2::instance_group_gid,
}
group{$db2::fenced_group:
gid => $db2::fenced_group_gid,
}
group{$db2::instance_user:
gid => $db2::instance_user_uid,
}
group{$db2::fenced_user:
gid => $db2::fenced_user_uid,
}
# Users
user{$db2::fenced_user:
uid => $db2::fenced_user_uid,
groups => $db2::fenced_group,
shell => $db2::fenced_user_shell,
password => pw_hash($db2::fenced_user_password,'sha-512', $db2::password_salt),
comment => 'db2 fenced user',
home => $db2::fenced_user_home,
require => Group[$db2::fenced_group],
}
user{$db2::instance_user:
uid => $db2::instance_user_uid,
groups => $db2::instance_group,
shell => $db2::instance_user_shell,
password => pw_hash($db2::instance_user_password,'sha-512', $db2::password_salt),
comment => 'instance user',
home => $db2::instance_user_home,
require => Group[$db2::instance_group],
}
file{$db2::instance_user_home:
ensure => directory,
owner => $db2::instance_user,
group => $db2::instance_group,
require => User[$db2::instance_user],
}
file{$db2::fenced_user_home:
ensure => directory,
owner => $db2::fenced_user,
group => $db2::fenced_group,
require => User[$db2::fenced_user],
}
# DB2 response file
$db2_response_file_path = "${db2::installer_source_dir}/exp/db2exp_${db2::instance_name}.rsp"
file{$db2_response_file_path:
content => template('db2/db2exp.rsp.erb'),
}
# Install db2
$exec_cmd_install_db2 = "${db2::installer_source_dir}/exp/db2setup -r ${db2_response_file_path}"
$db2ilist_path = "${db2::installer_target_dir}/bin/db2ilist"
$exec_unless_install_db2 = "${db2ilist_path} | grep -c ${db2::instance_name}"
exec{"install_db2_${db2::instance_name}":
command => $exec_cmd_install_db2,
unless => $exec_unless_install_db2,
before => Service[$db2::instance_name],
provider => 'shell',
timeout => $db2::setup_timeout,
require => [
User[$db2::instance_user],
User[$db2::fenced_user],
File[$db2::instance_user_home],
File[$db2::fenced_user_home],
],
}
# Disable fault monitor daemon since we're using systemd.
Exec { 'db2_disable_fault_monitor_daemon':
command => "${db2::installer_target_dir}/bin/db2fmcu -d",
unless => "${db2::installer_target_dir}/bin/db2fmcu | grep -i \"FMC\\:\\ down\"",
provider => 'shell',
require => Exec["install_db2_${db2::instance_name}"],
}
# For adm scripts.
if $db2::install_ksh {
ensure_resource(
'package',
'ksh',
{ ensure => present }
)
}
file { '/etc/profile.d/db2_bash_options.sh':
mode => '0644',
content => template('db2/db2_bash_options.sh.erb'),
}
}
|