Compare commits

...

39 commits

Author SHA1 Message Date
Micke Nordin b096522c36 Merge branch 'testing' 2024-10-09 14:27:29 +02:00
Micke Nordin d7e7e260c2 puppet-lint --fix 2024-10-09 14:26:06 +02:00
Micke Nordin 52869ca089 Fix mode on log files 2024-10-09 14:26:06 +02:00
Micke Nordin 1a39e0dbec Rollback fix 2024-10-09 14:26:06 +02:00
Micke Nordin e0c06d4571 We want full compat 2024-10-09 14:26:06 +02:00
Micke Nordin f29e074ded Add mysql command to host 2024-10-09 14:26:06 +02:00
Micke Nordin c761c56052 Add fix to init script from mandersson 2024-10-09 14:26:06 +02:00
Micke Nordin 026c5c5d03 Add audit log to other logs 2024-10-09 14:26:06 +02:00
Micke Nordin 5c0e05394d Fix mode on log files 2024-10-09 14:24:09 +02:00
Micke Nordin f2b8406826 Rollback fix 2024-10-09 14:24:09 +02:00
Micke Nordin 6d78fdde7c We want full compat 2024-10-09 14:24:09 +02:00
Micke Nordin 15beb333ec Add mysql command to host 2024-10-09 14:24:09 +02:00
Micke Nordin 8ca506f608 Add fix to init script from mandersson 2024-10-09 14:24:09 +02:00
Micke Nordin d3e0f41ff1 Rollback fix 2024-10-07 12:22:03 +02:00
Micke Nordin 8b74bd9c75 We want full compat 2024-10-07 12:22:03 +02:00
Micke Nordin 5c16a783e9 Add mysql command to host 2024-10-07 12:22:03 +02:00
Micke Nordin e4093f5e40 We want full compat 2024-10-04 10:05:20 +02:00
Micke Nordin 141f9334f2 Add mysql command to host 2024-10-04 10:01:17 +02:00
Micke Nordin 07ddb2220a format 2024-10-04 10:01:17 +02:00
Micke Nordin ccdb53310d Add fix to init script from mandersson 2024-10-03 14:18:52 +02:00
Micke Nordin 260fd526fe Use all adresses 2024-10-02 17:39:01 +02:00
Magnus Andersson e3697719d2
twofactor_enforced: Make template work with nil values 2024-10-01 11:26:10 +02:00
Magnus Andersson 766c337cb2
twofactor_enforced: Change manifest to work with fullnode 2024-10-01 11:25:25 +02:00
Micke Nordin cf0a778781 Add uptime check taht warns if server has been up for too long 2024-09-24 22:31:26 +02:00
Micke Nordin 911edbed58 Node3 sunet-prod reinstalled 2024-09-24 18:11:00 +02:00
Micke Nordin f8dce117a8 Correct hostgroup name 2024-09-24 17:47:32 +02:00
Micke Nordin dbac473c26 Move nrpe class from opsrepo 2024-09-24 17:30:21 +02:00
Micke Nordin 1822ecd683 Add audit log to other logs 2024-09-24 15:36:43 +02:00
Micke Nordin e20e41edf8 Move hee from cosmos-sites.pp 2024-09-23 17:05:08 +02:00
Micke Nordin 59e137e918 Merge branch 'main' into testing 2024-09-18 12:38:39 +02:00
Micke Nordin e4ccdde169 Create parent dir 2024-09-12 17:27:36 +02:00
Magnus Andersson 6827c0af7c
Dump customer datastructure for statistics logic to be transferred to script1. 2024-09-09 16:22:37 +02:00
Micke Nordin bff8d8ab22 Don't use incudes like this in newer puppet 2024-09-09 16:03:55 +02:00
Magnus Andersson 75c3a77c6d
Gen users on department lists by a cronjob. 2024-09-03 14:33:46 +02:00
Magnus Andersson eac5b172f2
genusersondepartmentlists: Make status count 2024-09-03 13:43:43 +02:00
Magnus Andersson 05bde6adb6
genusersondepartmentlists: Add som logic for error handling 2024-09-03 12:43:13 +02:00
Magnus Andersson d8eaa122e3
Lookup statistics secret on multinode-db1 in env test. 2024-09-03 10:06:05 +02:00
Magnus Andersson 7402202b9a
multinode-db1: Add initial upload logic of deprtment filtered user lists. 2024-08-30 15:39:01 +02:00
Magnus Andersson 60cb53e631
multinode-db1: Add logic and template to create userlists by department. 2024-08-30 08:57:17 +02:00
3 changed files with 58 additions and 0 deletions

View file

@ -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'],
}
} }
} }

View file

@ -0,0 +1 @@
<%= @custdata.to_json %>

View 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}