Merge branch 'main' into 8414_Fix_Permission_Denied_bacula_after_sh
This commit is contained in:
commit
c7d89c0043
|
@ -0,0 +1,35 @@
|
|||
- name: Gather facts from host and debug
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
|
||||
- name: Print ansible facts
|
||||
tags: facts
|
||||
debug:
|
||||
var: ansible_facts
|
||||
|
||||
- name: Print all variables
|
||||
tags: vars
|
||||
debug:
|
||||
var: vars
|
||||
|
||||
- name: Print variable value
|
||||
tags: var
|
||||
when: var_name is defined
|
||||
debug:
|
||||
msg: "{{ var_name }}: {{ lookup('vars', var_name, default='undefined') }}"
|
||||
|
||||
- name: Check whether host is alive and reachable
|
||||
tags: ping
|
||||
ping:
|
||||
|
||||
- name: Fetch or create passbolt password
|
||||
tags: passbolt
|
||||
debug:
|
||||
msg: "{{ lookup(passbolt, 'test', password=passbolt_password) }}"
|
||||
vars:
|
||||
passbolt_password: 'S3cR3tP4$$w0rd'
|
||||
environment:
|
||||
PASSBOLT_CREATE_NEW_RESOURCE: true
|
||||
PASSBOLT_NEW_RESOURCE_PASSWORD_LENGTH: 18
|
||||
PASSBOLT_NEW_RESOURCE_PASSWORD_SPECIAL_CHARS: false
|
|
@ -1,10 +0,0 @@
|
|||
- name: Gather facts from host
|
||||
hosts: all
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Print all available facts
|
||||
debug:
|
||||
var: ansible_facts
|
||||
- name: Print variable value
|
||||
debug:
|
||||
msg: "Variable: {{ ansible_fqdn }}"
|
|
@ -1,12 +0,0 @@
|
|||
- name: Fetch or create passbolt password
|
||||
hosts: all
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- debug:
|
||||
msg: "{{ lookup(passbolt, 'test', password=passbolt_password) }}"
|
||||
vars:
|
||||
passbolt_password: 'S3cR3tP4$$w0rd'
|
||||
environment:
|
||||
PASSBOLT_CREATE_NEW_RESOURCE: true
|
||||
PASSBOLT_NEW_RESOURCE_PASSWORD_LENGTH: 18
|
||||
PASSBOLT_NEW_RESOURCE_PASSWORD_SPECIAL_CHARS: false
|
|
@ -1,6 +0,0 @@
|
|||
- name: Check whether host is alive and reachable
|
||||
hosts: all
|
||||
gather_facts: no
|
||||
become: no
|
||||
tasks:
|
||||
- ping:
|
|
@ -6,6 +6,9 @@ myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||
. "$myDir/config.sh"
|
||||
|
||||
backupFile=$1
|
||||
formatted_date() {
|
||||
date '+%Y-%m-%d %H:%M:%S'
|
||||
}
|
||||
|
||||
if [ -z "$backupFile" ]; then
|
||||
echo "Backup file not defined."
|
||||
|
@ -22,6 +25,7 @@ echo "Restoring MySQL data from backup."
|
|||
rm -rf "$restoreDir"
|
||||
mkdir -p "$restoreDir"
|
||||
|
||||
echo "$(formatted_date)"
|
||||
echo "Decompresing backup."
|
||||
gzip --decompress --stdout "$backupFile" \
|
||||
| mbstream -x --directory="$restoreDir"
|
||||
|
@ -32,6 +36,7 @@ mariabackup \
|
|||
--prepare \
|
||||
--target-dir="$restoreDir"
|
||||
|
||||
echo "$(formatted_date)"
|
||||
echo "Stopping service."
|
||||
service mariadb stop
|
||||
if pgrep mariadbd; then pkill -9 mariadbd; fi
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
*/30 * * * * root /root/scripts/scheduler-log.sh
|
|
@ -3,7 +3,9 @@ set -e
|
|||
|
||||
logFile="/var/log/mysql/error.log"
|
||||
dateFile="/tmp/mysql_scheduler_log-lastdate"
|
||||
logTable="util.eventLog"
|
||||
logSchema="util"
|
||||
logTable="eventLog"
|
||||
pattern='^\d{4}-\d{2}-\d{2}\s+\d{1,2}:\d{2}:\d{2}\s+\d+\s+\[ERROR\] Event Scheduler:'
|
||||
purgeDays=30
|
||||
|
||||
quote() {
|
||||
|
@ -17,33 +19,55 @@ if [ "$?" -ne "0" ]; then
|
|||
exit
|
||||
fi
|
||||
|
||||
if [ -f "$dateFile" ]; then
|
||||
fromDate=$(cat "$dateFile")
|
||||
else
|
||||
fromDate=0
|
||||
tableExists=$(mysql -Ns -e "SHOW TABLES FROM $logSchema LIKE '$logTable'")
|
||||
|
||||
if [ -z "$tableExists" ]; then
|
||||
mysql <<-EOF
|
||||
CREATE SCHEMA IF NOT EXISTS $logSchema;
|
||||
CREATE TABLE $logSchema.$logTable (
|
||||
id int(11) NOT NULL AUTO_INCREMENT,
|
||||
date datetime NOT NULL,
|
||||
event varchar(512) NOT NULL,
|
||||
error varchar(1024) NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
KEY date (date)
|
||||
) ENGINE=InnoDB COMMENT='Event scheduler error log';
|
||||
EOF
|
||||
fi
|
||||
|
||||
lastDate=$(tail -n1 "$logFile" | awk '{print $1" "$2}')
|
||||
toDate=$(date +%s -d "$lastDate")
|
||||
if [ -f "$dateFile" ]; then
|
||||
read -r fromDate < "$dateFile"
|
||||
else
|
||||
fromDate=$(date -d "-$purgeDays days" +%s)
|
||||
fi
|
||||
|
||||
awk -v fromDate="$fromDate" -v toDate="$toDate" '{
|
||||
toDate=$(date +%s)
|
||||
|
||||
grep -P "$pattern" "$logFile" | awk -v fromDate="$fromDate" -v toDate="$toDate" '{
|
||||
split($1, date, "-");
|
||||
split($2, time, ":");
|
||||
timestamp = mktime(date[1]" "date[2]" "date[3]" "time[1]" "time[2]" "time[3])
|
||||
if (timestamp >= fromDate && timestamp < toDate && $4" "$5" "$6 == "[ERROR] Event Scheduler:") {
|
||||
if (timestamp >= fromDate && timestamp < toDate) {
|
||||
printf $1" "$2" "$7;
|
||||
for (i=8; i<=NF; i++) printf FS $i ;
|
||||
print "";
|
||||
}
|
||||
}' "$logFile" | \
|
||||
\
|
||||
}' | \
|
||||
while read line; do
|
||||
date="$(echo "$line" | cut -d' ' -f1,2)"
|
||||
event="$(echo "$line" | cut -d' ' -f3)"
|
||||
error="$(echo "$line" | cut -d' ' -f4-)"
|
||||
echo "INSERT INTO $logTable (date, event, error)" \
|
||||
"VALUES ($(quote "$date"), $(quote "$event"), $(quote "$error"))" | mysql
|
||||
|
||||
mysql <<-EOF
|
||||
INSERT INTO $logSchema.$logTable SET
|
||||
date = $(quote "$date"),
|
||||
event = $(quote "$event"),
|
||||
error = $(quote "$error")
|
||||
EOF
|
||||
done
|
||||
|
||||
echo -n "$toDate" > "$dateFile"
|
||||
echo "DELETE FROM $logTable WHERE date < TIMESTAMPADD(DAY, -$purgeDays, NOW())" | mysql
|
||||
echo "$toDate" > "$dateFile"
|
||||
mysql <<-EOF
|
||||
DELETE FROM $logSchema.$logTable
|
||||
WHERE date < TIMESTAMPADD(DAY, -$purgeDays, NOW())
|
||||
EOF
|
||||
|
|
|
@ -45,8 +45,16 @@
|
|||
|
||||
- name: Set MariaDB Cron to /etc/cron.d
|
||||
template:
|
||||
src: templates/cron_mariadb
|
||||
dest: /etc/cron.d/vn
|
||||
src: check-memory.cron
|
||||
dest: /etc/cron.d/vn-check-memory
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
|
||||
- name: Configure MariaDB scheduler log CRON
|
||||
copy:
|
||||
src: scheduler-log.cron
|
||||
dest: /etc/cron.d/vn-scheduler-log
|
||||
owner: root
|
||||
group: root
|
||||
mode: u=rw,g=r,o=r
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
MAILTO="{{ sysadmin_mail }}"
|
||||
|
||||
*/15 * * * * root /root/scripts/check-memory.sh
|
||||
*/30 * * * * root /root/scripts/scheduler-log.sh
|
|
@ -1,6 +1,7 @@
|
|||
vn_env: lab
|
||||
vn_first_time: false
|
||||
vn_witness_checked: false
|
||||
send_test_email: true
|
||||
deb_packages:
|
||||
- https://apt.verdnatura.es/pool/main/v/vn-host/vn-apt-source_3.0.1_all.deb
|
||||
- https://apt.verdnatura.es/pool/main/v/vn-host/vn-host_3.0.1_all.deb
|
||||
|
|
|
@ -11,6 +11,8 @@ if [ -f "/etc/vn/env" ]; then
|
|||
fi
|
||||
|
||||
read -r VN_ENV < /etc/vn/env
|
||||
ENV_TEXT="$VN_ENV"
|
||||
|
||||
case "$VN_ENV" in
|
||||
lab)
|
||||
ENV_COLOR="\033[01;32m"
|
||||
|
@ -26,17 +28,16 @@ if [ -f "/etc/vn/env" ]; then
|
|||
;;
|
||||
*)
|
||||
ENV_COLOR="\033[01;36m"
|
||||
ENV_TEXT="${VN_ENV:0:3}"
|
||||
;;
|
||||
esac
|
||||
|
||||
ENV_TEXT=${VN_ENV^^}
|
||||
|
||||
if [ -z "$ENV_TEXT" ]; then
|
||||
ENV_TEXT="???"
|
||||
ENV_COLOR="\033[01;37m"
|
||||
fi
|
||||
|
||||
ENV_TEXT="\[${ENV_COLOR}\]${ENV_TEXT}\[\033[00m\]"
|
||||
ENV_TEXT="\[${ENV_COLOR}\]${ENV_TEXT^^}\[\033[00m\]"
|
||||
PS1="\u@$SHORT_HOST[$ENV_TEXT]:\w"
|
||||
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
|
|
|
@ -27,7 +27,11 @@
|
|||
- name: Force execution of handlers immediately
|
||||
meta: flush_handlers
|
||||
- name: Sending mail to verify relay host configuration works
|
||||
when: >
|
||||
exim_config.changed
|
||||
and send_test_email
|
||||
and awx_user_email is defined
|
||||
and awx_user_email | length > 0
|
||||
shell: >
|
||||
sleep 2; echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \
|
||||
| mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}"
|
||||
when: exim_config.changed
|
||||
| mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ awx_user_email }}"
|
||||
|
|
Loading…
Reference in New Issue