Compare commits
39 commits
7460019ec5
...
b096522c36
Author | SHA1 | Date | |
---|---|---|---|
Micke Nordin | b096522c36 | ||
Micke Nordin | d7e7e260c2 | ||
Micke Nordin | 52869ca089 | ||
Micke Nordin | 1a39e0dbec | ||
Micke Nordin | e0c06d4571 | ||
Micke Nordin | f29e074ded | ||
Micke Nordin | c761c56052 | ||
Micke Nordin | 026c5c5d03 | ||
Micke Nordin | 5c0e05394d | ||
Micke Nordin | f2b8406826 | ||
Micke Nordin | 6d78fdde7c | ||
Micke Nordin | 15beb333ec | ||
Micke Nordin | 8ca506f608 | ||
Micke Nordin | d3e0f41ff1 | ||
Micke Nordin | 8b74bd9c75 | ||
Micke Nordin | 5c16a783e9 | ||
Micke Nordin | e4093f5e40 | ||
Micke Nordin | 141f9334f2 | ||
Micke Nordin | 07ddb2220a | ||
Micke Nordin | ccdb53310d | ||
Micke Nordin | 260fd526fe | ||
Magnus Andersson | e3697719d2 | ||
Magnus Andersson | 766c337cb2 | ||
Micke Nordin | cf0a778781 | ||
Micke Nordin | 911edbed58 | ||
Micke Nordin | f8dce117a8 | ||
Micke Nordin | dbac473c26 | ||
Micke Nordin | 1822ecd683 | ||
Micke Nordin | e20e41edf8 | ||
Micke Nordin | 59e137e918 | ||
Micke Nordin | e4ccdde169 | ||
Magnus Andersson | 6827c0af7c | ||
Micke Nordin | bff8d8ab22 | ||
Magnus Andersson | 75c3a77c6d | ||
Magnus Andersson | eac5b172f2 | ||
Magnus Andersson | 05bde6adb6 | ||
Magnus Andersson | d8eaa122e3 | ||
Magnus Andersson | 7402202b9a | ||
Magnus Andersson | 60cb53e631 |
|
@ -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