72 lines
2.7 KiB
Puppet
72 lines
2.7 KiB
Puppet
class sunetdrive::multinode_db(){
|
|
$is_multinode = true;
|
|
$environment = sunetdrive::get_environment()
|
|
$allcustomers = hiera_hash('multinode_mapping')
|
|
$customers = $allcustomers.keys
|
|
|
|
$customers.each |$customer| {
|
|
file { "/etc/mariadb/backups/${customer}":
|
|
ensure => directory,
|
|
}
|
|
file { "/etc/mariadb/init/04-nextcloud.${customer}.sql":
|
|
ensure => present,
|
|
content => "CREATE SCHEMA nextcloud_${customer};\nCREATE USER 'nextcloud_${customer}'@'%' IDENTIFIED BY '${hiera("${customer}_mysql_user_password")}';\nGRANT ALL PRIVILEGES ON nextcloud_${customer}.* TO 'nextcloud_${customer}'@'%' IDENTIFIED BY '${hiera("${customer}_mysql_user_password")}';\n",
|
|
mode => '0744',
|
|
}
|
|
}
|
|
if $facts["networking"]["fqdn"] =~ /^multinode-db1\.drive\.(test\.){1}sunet\.se$/ {
|
|
$statistics_secret = safe_hiera('statistics_secret')
|
|
notify { 'hostmessage':
|
|
message => 'We are on multinode-db1. Set up statistics environment.',
|
|
}
|
|
$rclone_url = 'https://downloads.rclone.org/rclone-current-linux-amd64.deb'
|
|
$local_path = '/tmp/rclone-current-linux-amd64.deb'
|
|
exec { 'rclone_deb':
|
|
command => "/usr/bin/wget -q ${rclone_url} -O ${local_path}",
|
|
creates => $local_path,
|
|
}
|
|
package { 'rclone':
|
|
ensure => installed,
|
|
provider => dpkg,
|
|
source => $local_path,
|
|
require => Exec['rclone_deb'],
|
|
}
|
|
file { '/root/.rclone.conf':
|
|
ensure => file,
|
|
content => template('sunetdrive/mariadb_backup/rclone.conf.erb'),
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0600',
|
|
}
|
|
file { '/root/tasks/listusersbydep.sh':
|
|
ensure => file,
|
|
content => template('sunetdrive/mariadb/listusersdep.sh.erb'),
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0700',
|
|
}
|
|
file { '/root/tasks/genusersondepartmentlists.sh':
|
|
ensure => file,
|
|
content => template('sunetdrive/mariadb/genuserdeplists.sh.erb'),
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0700',
|
|
}
|
|
file {'/opt/mariadb/statistics/custdata.json':
|
|
ensure => file,
|
|
content => template('sunetdrive/mariadb/custconfig.json.erb'),
|
|
owner => 'root',
|
|
group => 'root',
|
|
mode => '0600',
|
|
}
|
|
sunet::scriptherder::cronjob { 'genuserdeplists':
|
|
cmd => '/root/tasks/genusersondepartmentlists.sh',
|
|
hour => '2',
|
|
minute => '5',
|
|
ok_criteria => ['exit_status=0','max_age=30h'],
|
|
warn_criteria => ['exit_status=1', 'max_age=60h'],
|
|
}
|
|
}
|
|
}
|
|
|