Allow connections from kubeservers to multinode db
This commit is contained in:
parent
0e5653aa0c
commit
a21ea6fdd5
1 changed files with 57 additions and 70 deletions
|
@ -7,20 +7,9 @@ define sunetdrive::db_type(
|
||||||
$override_compose = undef,
|
$override_compose = undef,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
# Config from group.yaml
|
# Config from group.yaml
|
||||||
$environment = sunetdrive::get_environment()
|
$environment = sunetdrive::get_environment()
|
||||||
$mariadb_version = hiera("mariadb_version_${environment}")
|
$mariadb_version = hiera("mariadb_version_${environment}")
|
||||||
$is_multinode = (($override_config != undef) and ($override_compose != undef))
|
|
||||||
if $is_multinode {
|
|
||||||
$config = $override_config
|
|
||||||
$mysql_root_password = $config['mysql_root_password']
|
|
||||||
$mysql_user_password = $config['mysql_user_password']
|
|
||||||
$backup_password = $config['backup_password']
|
|
||||||
$mariadb_dir = $config['mariadb_dir']
|
|
||||||
$mycnf_path = $config['mycnf_path']
|
|
||||||
$server_id = '1000'
|
|
||||||
} else {
|
|
||||||
$config = hiera_hash($environment)
|
$config = hiera_hash($environment)
|
||||||
$mysql_root_password = safe_hiera('mysql_root_password')
|
$mysql_root_password = safe_hiera('mysql_root_password')
|
||||||
$backup_password = safe_hiera('backup_password')
|
$backup_password = safe_hiera('backup_password')
|
||||||
|
@ -34,23 +23,25 @@ define sunetdrive::db_type(
|
||||||
$dirs.each |$dir| {
|
$dirs.each |$dir| {
|
||||||
ensure_resource('file',"${mariadb_dir}/${dir}", { ensure => directory, recurse => true } )
|
ensure_resource('file',"${mariadb_dir}/${dir}", { ensure => directory, recurse => true } )
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$nextcloud_ip = $config['app']
|
$nextcloud_ip = $config['app']
|
||||||
|
|
||||||
unless $is_multinode {
|
|
||||||
$db_ip = $config['db']
|
$db_ip = $config['db']
|
||||||
$db_ipv6 = $config['db_v6']
|
$db_ipv6 = $config['db_v6']
|
||||||
$backup_ip = $config['backup']
|
$backup_ip = $config['backup']
|
||||||
$backup_ipv6 = $config['backup_v6']
|
$backup_ipv6 = $config['backup_v6']
|
||||||
$ports = [3306, 4444, 4567, 4568]
|
$ports = [3306, 4444, 4567, 4568]
|
||||||
|
if $location =~ /^multinode/ {
|
||||||
|
$from = $db_ip + $nextcloud_ip + $backup_ip + $backup_ipv6 + $db_ipv6 + $config['kube'] + $config['kube_v6']
|
||||||
|
} else {
|
||||||
|
$from = $db_ip + $nextcloud_ip + $backup_ip + $backup_ipv6 + $db_ipv6
|
||||||
|
}
|
||||||
|
|
||||||
sunet::misc::ufw_allow { 'mariadb_ports':
|
sunet::misc::ufw_allow { 'mariadb_ports':
|
||||||
from => $db_ip + $nextcloud_ip + $backup_ip + $backup_ipv6 + $db_ipv6,
|
from => $from,
|
||||||
port => $ports,
|
port => $ports,
|
||||||
}
|
}
|
||||||
sunet::system_user {'mysql': username => 'mysql', group => 'mysql' }
|
sunet::system_user {'mysql': username => 'mysql', group => 'mysql' }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if $location =~ /^lookup/ {
|
if $location =~ /^lookup/ {
|
||||||
|
@ -97,9 +88,6 @@ define sunetdrive::db_type(
|
||||||
ok_criteria => ['exit_status=0','max_age=2d'],
|
ok_criteria => ['exit_status=0','max_age=2d'],
|
||||||
warn_criteria => ['exit_status=1','max_age=3d'],
|
warn_criteria => ['exit_status=1','max_age=3d'],
|
||||||
}
|
}
|
||||||
if $is_multinode {
|
|
||||||
$docker_compose = $override_compose
|
|
||||||
} else {
|
|
||||||
file { '/usr/local/bin/size-test':
|
file { '/usr/local/bin/size-test':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
content => template('sunetdrive/mariadb/size-test.erb'),
|
content => template('sunetdrive/mariadb/size-test.erb'),
|
||||||
|
@ -131,5 +119,4 @@ define sunetdrive::db_type(
|
||||||
compose_filename => 'docker-compose.yml',
|
compose_filename => 'docker-compose.yml',
|
||||||
description => 'Mariadb server',
|
description => 'Mariadb server',
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue