library/roles/mysql: Fix the backup script. Now it finds the installed databases in a sane way.

library/roles/nginx: Option to activate the gzip compression.
This commit is contained in:
Andrea Dell'Amico 2015-08-05 19:14:03 +02:00
parent 72e03b7851
commit abf68e19e5
6 changed files with 42 additions and 32 deletions

View File

@ -16,6 +16,7 @@ mw_php_prereq:
- php5-mysqlnd
- php-apc
- php-pear
- php5-ldap
- imagemagick
# This choice is not recommended. The package has a poor list of dependencies. We do not want to deal with those

View File

@ -43,4 +43,5 @@ mysql_backup_logdir: '{{ mysql_log_dir }}'
mysql_backup_logfile: '{{ mysql_backup_logdir }}/my_backup.log'
mysql_backup_retain_copies: 15
mysql_backup_destdir: /var/lib/mysql-backup
mysql_backup_exclude_list: "performance_schema"

View File

@ -6,6 +6,8 @@ MY_BACKUP_USE_NAGIOS="False"
MY_BACKUP_DIR=/var/lib/mysql-backup
MY_DATA_DIR=/var/lib/mysql
N_DAYS_TO_SPARE=7
# Exclude list
EXCLUDE_LIST='performance_schema'
if [ -f /etc/default/mysql_backup ] ; then
. /etc/default/mysql_backup
@ -33,33 +35,28 @@ fi
chmod 700 $MY_BACKUP_DIR
LOCKFILE=$MY_DATA_DIR/.mysqldump.lock
NAGIOS_LOG=$MY_BACKUP_DIR/.nagios-status
# Exclude list
EXCLUDE_LIST='performance_schema'
if [ ! -f $LOCKFILE ] ; then
touch $LOCKFILE
if [ "${MY_BACKUP_USE_NAGIOS}" == "True" ] ; then
> $NAGIOS_LOG
fi
for db in $( /bin/ls -1 /var/lib/mysql/ | grep -v $EXCLUDE_LIST ) ; do
if [ -d /var/lib/mysql/$db ] ; then
#mysqldump -uroot -f --opt -p$MYSQLPASS $db > $MY_BACKUP_DIR/$db.sql 2> $MY_BACKUP_DIR/log/$db.log
mysqldump -f --opt $db > $MY_BACKUP_DIR/history/${db}.sql.${SAVE_TIME} 2> $MY_BACKUP_LOG_DIR/$db.log
DUMP_RESULT=$?
chmod 600 $MY_BACKUP_DIR/history/${db}.sql.${SAVE_TIME}
if [ "${MY_BACKUP_USE_NAGIOS}" == "True" ] ; then
if [ $DUMP_RESULT -ne 0 ] ; then
echo "$db:FAILED" >> $NAGIOS_LOG
RETVAL=$DUMP_RESULT
else
echo "$db:OK" >> $NAGIOS_LOG
fi
fi
pushd ${MY_BACKUP_DIR}/ >/dev/null 2>&1
rm -f $db.sql
ln -s $MY_BACKUP_DIR/history/${db}.sql.${SAVE_TIME} ./$db.sql
popd >/dev/null 2>&1
fi
for db in $( mysql -Bse "show databases;" | grep -v $EXCLUDE_LIST ) ; do
mysqldump -f --flush-privileges --opt $db > $MY_BACKUP_DIR/history/${db}.sql.${SAVE_TIME} 2> $MY_BACKUP_LOG_DIR/$db.log
DUMP_RESULT=$?
chmod 600 $MY_BACKUP_DIR/history/${db}.sql.${SAVE_TIME}
if [ "${MY_BACKUP_USE_NAGIOS}" == "True" ] ; then
if [ $DUMP_RESULT -ne 0 ] ; then
echo "$db:FAILED" >> $NAGIOS_LOG
RETVAL=$DUMP_RESULT
else
echo "$db:OK" >> $NAGIOS_LOG
fi
fi
pushd ${MY_BACKUP_DIR}/ >/dev/null 2>&1
rm -f $db.sql
ln -s $MY_BACKUP_DIR/history/${db}.sql.${SAVE_TIME} ./$db.sql
popd >/dev/null 2>&1
done
# Do a "flush-hosts" after the backup
mysqladmin flush-hosts 2> $MY_BACKUP_LOG_DIR/flush-hosts.log

View File

@ -4,3 +4,5 @@ MY_BACKUP_LOG_FILE='{{ mysql_backup_logfile}}'
N_DAYS_TO_SPARE='{{ mysql_backup_retain_copies }}'
MY_BACKUP_DIR='{{ mysql_backup_destdir }}'
MY_DATA_DIR='{{ mysql_data_dir }}'
# Exclude list
EXCLUDE_LIST='{{ mysql_backup_exclude_list }}'

View File

@ -5,6 +5,14 @@ nginx_ldap_uri: "ldap://ldap.sub.research-infrastructures.eu"
nginx_ldap_base_dn: "dc=research-infrastructures,dc=eu"
nginx_enabled: "Yes"
nginx_enable_compression: True
nginx_gzip_vary: "on"
nginx_gzip_proxied: any
nginx_gzip_comp_level: 6
nginx_gzip_buffers: 16 8k
nginx_gzip_http_version: 1.1
nginx_gzip_types: "text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript"
nginx_proxy_buffering: "on"
nginx_proxy_redirect: "off"
nginx_proxy_buffer_size: 128k

View File

@ -4,25 +4,26 @@
with_items:
- nginx-full
when: not nginx_use_ldap_pam_auth
tags:
- nginx
tags: nginx
- name: Install the nginx web server if we need ldap auth via pam
apt: pkg={{ item }} state=installed
with_items:
with_items:
- nginx-extras
when: nginx_use_ldap_pam_auth
tags:
- nginx
tags: nginx
- name: remove nginx default config
file: dest=/etc/nginx/sites-enabled/default state=absent
notify:
Reload nginx
tags:
- nginx
notify: Reload nginx
tags: [ 'nginx', 'nginx_conf', 'nginx_virtualhost' ]
- name: Install the gzip compression configuration if enabled
template: src=nginx-compression.conf.j2 dest=/etc/nginx/conf.d/compression.conf owner=root group=root mode=0444
when: nginx_enable_compression
notify: Reload nginx
tags: [ 'nginx', 'nginx_conf' ]
- name: Ensure that the webserver is running
service: name=nginx state=started enabled={{ nginx_enabled }}
tags:
- nginx
tags: nginx