Merge branch 'testing'
This commit is contained in:
commit
b096522c36
|
@ -15,9 +15,13 @@ class sunetdrive::multinode_db(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if $facts["networking"]["fqdn"] =~ /^multinode-db1\.drive\.(test\.){1}sunet\.se$/ {
|
if $facts["networking"]["fqdn"] =~ /^multinode-db1\.drive\.(test\.){1}sunet\.se$/ {
|
||||||
|
$statistics_secret = safe_hiera('statistics_secret')
|
||||||
notify { 'hostmessage':
|
notify { 'hostmessage':
|
||||||
message => 'We are on multinode-db1. Set up statistics environment.',
|
message => 'We are on multinode-db1. Set up statistics environment.',
|
||||||
}
|
}
|
||||||
|
$custdata=$customers.reduce({}) |$memo, $value| {
|
||||||
|
$memo + {$value => lookup($value)}
|
||||||
|
}
|
||||||
$rclone_url = 'https://downloads.rclone.org/rclone-current-linux-amd64.deb'
|
$rclone_url = 'https://downloads.rclone.org/rclone-current-linux-amd64.deb'
|
||||||
$local_path = '/tmp/rclone-current-linux-amd64.deb'
|
$local_path = '/tmp/rclone-current-linux-amd64.deb'
|
||||||
exec { 'rclone_deb':
|
exec { 'rclone_deb':
|
||||||
|
@ -44,5 +48,26 @@ class sunetdrive::multinode_db(){
|
||||||
group => 'root',
|
group => 'root',
|
||||||
mode => '0700',
|
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'],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
templates/mariadb/custconfig.json.erb
Normal file
1
templates/mariadb/custconfig.json.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= @custdata.to_json %>
|
32
templates/mariadb/genuserdeplists.sh.erb
Normal file
32
templates/mariadb/genuserdeplists.sh.erb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
<% basedir="statistics:drive-server-coms" -%>
|
||||||
|
<% cupath="/opt/mariadb/statistics/users/" -%>
|
||||||
|
<% custdata="/opt/mariadb/statistics/custdata.json" -%>
|
||||||
|
status=0
|
||||||
|
|
||||||
|
<% @custdata.each do |cust,data| -%>
|
||||||
|
#Customer <%= cust %> has no billing departments.
|
||||||
|
<% if defined?(data[@environment]["billdomains"]) && data[@environment]["billdomains"] -%>
|
||||||
|
mkdir -p /opt/mariadb/statistics/users/<%= cust %>
|
||||||
|
chmod '0700' /opt/mariadb/statistics/users/<%= cust %>
|
||||||
|
<% data[@environment]["billdomains"].each do |dom| -%>
|
||||||
|
/root/tasks/listusersbydep.sh <%= cust %> <%= dom %> > /opt/mariadb/statistics/users/<%= cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json
|
||||||
|
if jq . <%= cupath + cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json &>/dev/null
|
||||||
|
then
|
||||||
|
timeout 30s rclone copy -c --no-check-certificate --webdav-headers "Host,sunet.drive.sunet.se" --use-cookies <%= cupath + cust %>/users-<%= dom.gsub(/[.]/, '-') %>.json <%= basedir%>/<%= cust %>-<%= @environment%>/
|
||||||
|
[[ $? -eq 0 ]] || { status=1 ; echo "Error: Upload of user data failed." ; }
|
||||||
|
else
|
||||||
|
echo "Error in json data"
|
||||||
|
status=1
|
||||||
|
fi
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
if [[ -f <%= custdata %> ]]
|
||||||
|
then
|
||||||
|
timeout 30s rclone copy -c --no-check-certificate --webdav-headers "Host,sunet.drive.sunet.se" --use-cookies <%= custdata %> <%= basedir%>/
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit ${status}
|
Loading…
Reference in a new issue