better backps, gitea up to date

This commit is contained in:
LUXEY Adrien 2020-06-30 13:46:59 +02:00
parent 8e1e2beb47
commit 6742104999
3 changed files with 176 additions and 168 deletions

View file

@ -11,7 +11,7 @@ wordpress:
version: 5.4 version: 5.4
checksum: sha1:d5f1e6d7cadd72c11d086a2e1ede0a72f23d993e checksum: sha1:d5f1e6d7cadd72c11d086a2e1ede0a72f23d993e
gitea: gitea:
version: 1.11.4 version: 1.12.1
synapse: synapse:
version: v1.15.1-py3 version: v1.15.1-py3
@ -19,118 +19,118 @@ postgres:
pg_hba_path: "/etc/postgresql/9.6/main/pg_hba.conf" pg_hba_path: "/etc/postgresql/9.6/main/pg_hba.conf"
sites: sites:
# - slug: rdb # Shorthand name to use as directory/file name - slug: rdb # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: rennesdesbois.fr url: rennesdesbois.fr
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: yes redirect_to_www: yes
# # What kind of site is that? # What kind of site is that?
# type: wordpress type: wordpress
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.1.0/24 subnet_cidr_address: 172.27.1.0/24
# subnet_gateway_ip: 172.27.1.1 subnet_gateway_ip: 172.27.1.1
# subnet_nginx_ip: 172.27.1.2 subnet_nginx_ip: 172.27.1.2
# subnet_site_ip: 172.27.1.3 subnet_site_ip: 172.27.1.3
# # MySQL # MySQL
# mysql_database: rdb mysql_database: rdb
# mysql_username: rdb mysql_username: rdb
# mysql_password: "{{ vault_rdb_mysql_password }}" mysql_password: "{{ vault_rdb_mysql_password }}"
# - slug: arvuhez # Shorthand name to use as directory/file name - slug: arvuhez # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: arvuhez.org url: arvuhez.org
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: no redirect_to_www: no
# # What kind of site is that? # What kind of site is that?
# type: wordpress type: wordpress
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.2.0/24 subnet_cidr_address: 172.27.2.0/24
# subnet_gateway_ip: 172.27.2.1 subnet_gateway_ip: 172.27.2.1
# subnet_nginx_ip: 172.27.2.2 subnet_nginx_ip: 172.27.2.2
# subnet_site_ip: 172.27.2.3 subnet_site_ip: 172.27.2.3
# # MySQL # MySQL
# mysql_database: arvuhez mysql_database: arvuhez
# mysql_username: arvuhez mysql_username: arvuhez
# mysql_password: "{{ vault_arvuhez_mysql_password }}" mysql_password: "{{ vault_arvuhez_mysql_password }}"
# - slug: zinzoscope # Shorthand name to use as directory/file name - slug: zinzoscope # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: zinz.luxeylab.net url: zinz.luxeylab.net
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: no redirect_to_www: no
# # What kind of site is that? # What kind of site is that?
# type: wordpress type: wordpress
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.3.0/24 subnet_cidr_address: 172.27.3.0/24
# subnet_gateway_ip: 172.27.3.1 subnet_gateway_ip: 172.27.3.1
# subnet_nginx_ip: 172.27.3.2 subnet_nginx_ip: 172.27.3.2
# subnet_site_ip: 172.27.3.3 subnet_site_ip: 172.27.3.3
# # MySQL # MySQL
# mysql_database: zinzoscope mysql_database: zinzoscope
# mysql_username: zinzoscope mysql_username: zinzoscope
# mysql_password: "{{ vault_zinzoscope_mysql_password }}" mysql_password: "{{ vault_zinzoscope_mysql_password }}"
# - slug: lexperimental # Shorthand name to use as directory/file name - slug: lexperimental # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: lexperimental.fr url: lexperimental.fr
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: no redirect_to_www: no
# # What kind of site is that? # What kind of site is that?
# type: wordpress type: wordpress
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.4.0/24 subnet_cidr_address: 172.27.4.0/24
# subnet_gateway_ip: 172.27.4.1 subnet_gateway_ip: 172.27.4.1
# subnet_nginx_ip: 172.27.4.2 subnet_nginx_ip: 172.27.4.2
# subnet_site_ip: 172.27.4.3 subnet_site_ip: 172.27.4.3
# # MySQL # MySQL
# mysql_database: lexperimental mysql_database: lexperimental
# mysql_username: lexperimental mysql_username: lexperimental
# mysql_password: "{{ vault_lexperimental_mysql_password }}" mysql_password: "{{ vault_lexperimental_mysql_password }}"
# - slug: mts # Shorthand name to use as directory/file name - slug: mts # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: editionsmangetasoupe.fr url: editionsmangetasoupe.fr
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: no redirect_to_www: no
# # What kind of site is that? # What kind of site is that?
# type: drupal type: drupal
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.5.0/24 subnet_cidr_address: 172.27.5.0/24
# subnet_gateway_ip: 172.27.5.1 subnet_gateway_ip: 172.27.5.1
# subnet_site_ip: 172.27.5.2 subnet_site_ip: 172.27.5.2
# # This will allow setting up MySQL # This will allow setting up MySQL
# # Configuration on Drupal's side must be done by hand: # Configuration on Drupal's side must be done by hand:
# # Edit your <drupal_install>/sites/default/settings.php # Edit your <drupal_install>/sites/default/settings.php
# mysql_database: mts8 mysql_database: mts8
# mysql_username: mts mysql_username: mts
# mysql_password: "{{ vault_mts_mysql_password }}" mysql_password: "{{ vault_mts_mysql_password }}"
# - slug: gitea # Shorthand name to use as directory/file name - slug: gitea # Shorthand name to use as directory/file name
# # The site URL (without www) # The site URL (without www)
# url: git.deuxfleurs.fr url: git.deuxfleurs.fr
# # Ask nginx to redirect url to www # Ask nginx to redirect url to www
# # Else, we redirect www to url # Else, we redirect www to url
# redirect_to_www: no redirect_to_www: no
# # What kind of site is that? # What kind of site is that?
# type: gitea type: gitea
# # Subnet addresses # Subnet addresses
# subnet_cidr_address: 172.27.6.0/24 subnet_cidr_address: 172.27.6.0/24
# subnet_gateway_ip: 172.27.6.1 subnet_gateway_ip: 172.27.6.1
# subnet_site_ip: 172.27.6.2 subnet_site_ip: 172.27.6.2
# # User IDs # User IDs
# user_name: git user_name: git
# user_uid: 1007 user_uid: 1007
# user_group: git user_group: git
# user_gid: 1006 user_gid: 1006
# # MySQL # MySQL
# mysql_database: gitea mysql_database: gitea
# mysql_username: gitea mysql_username: gitea
# mysql_password: "{{ vault_gitea_mysql_password }}" mysql_password: "{{ vault_gitea_mysql_password }}"
- slug: synapse # Shorthand name to use as directory/file name - slug: synapse # Shorthand name to use as directory/file name
# The site URL (without www) # The site URL (without www)

View file

@ -3,24 +3,17 @@
# - site: dict describing the site install (cf group_vars/all/vars.yml) # - site: dict describing the site install (cf group_vars/all/vars.yml)
# - site_data_path: path of the site's data # - site_data_path: path of the site's data
- name: "Data backups"
block: - name: "Setup periodic site files backup"
- name: "Setup weekly backup of site's data"
cron:
name: "backup {{ site.slug }} data"
# hour: "{{ 24 | random }}"
# minute: "{{ 60 | random }}"
special_time: weekly
user: "root"
job: "tar czf {{ backups_path }}/{{ site.slug }}.tar.gz {{ site_data_path }}"
become: yes
- name: "Setup data backup rotation with logrotate"
blockinfile: blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}" path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATA BACKUP" marker: "# {mark} DATA BACKUP"
create: yes create: yes
block: | block: |
{{ backups_path }}/{{ site.slug }}.tar.gz { {{ backups_path }}/{{ site.slug }}.tar.gz {
prerotate
tar czf {{ backups_path }}/{{ site.slug }}.tar.gz {{ site_data_path }}
endscript
weekly weekly
rotate 4 rotate 4
nocompress nocompress
@ -28,28 +21,22 @@
dateformat _%Y-%m-%d dateformat _%Y-%m-%d
extension .tar.gz extension .tar.gz
missingok missingok
su www-data www-data
nocreate
} }
become: yes become: yes
when: site_data_path is defined when: site_data_path is defined
- name: "MySQL Database backups" - name: "Setup periodic MySQL database backup"
block:
# You need your root MySQL password stored in /root/.my.cnf to avoid
# putting the password in the crontab
- name: "Setup weekly backup of database"
cron:
name: "backup {{ site.slug }} database"
special_time: weekly
user: "root" # need root for passwordless mysqldump
job: "mysqldump {{ site.mysql_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz"
become: yes
- name: "Setup database backup rotation with logrotate"
blockinfile: blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}" path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATABASE BACKUP" marker: "# {mark} DATABASE BACKUP"
create: yes create: yes
block: | block: |
{{ backups_path }}/{{ site.slug }}.sql.gz { {{ backups_path }}/{{ site.slug }}.sql.gz {
prerotate
mysqldump {{ site.mysql_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz
endscript
weekly weekly
rotate 4 rotate 4
nocompress nocompress
@ -57,10 +44,31 @@
dateformat _%Y-%m-%d dateformat _%Y-%m-%d
extension .sql.gz extension .sql.gz
missingok missingok
su www-data www-data
nocreate
} }
become: yes become: yes
when: site.mysql_database is defined when: site.mysql_database is defined
- name: "PostgreSQL Database backups" - name: "Setup periodic PostgreSQL database backup"
debug: msg="TODO PUTAIN BOSSE LÀ" blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATABASE BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.sql.gz {
prerotate
sudo -u postgres pg_dump {{ site.postgres_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .sql.gz
missingok
su www-data www-data
nocreate
}
become: yes
when: site.postgres_database is defined when: site.postgres_database is defined

View file

@ -6,7 +6,7 @@
loop_control: loop_control:
loop_var: site loop_var: site
when: site.type == "wordpress" when: site.type == "wordpress"
tags: wordpress tags: wordpress,sites
- name: Build Drupal sites - name: Build Drupal sites
include_tasks: drupal.yml include_tasks: drupal.yml
@ -14,7 +14,7 @@
loop_control: loop_control:
loop_var: site loop_var: site
when: site.type == "drupal" when: site.type == "drupal"
tags: drupal tags: drupal,sites
- name: Build Gitea sites - name: Build Gitea sites
include_tasks: gitea.yml include_tasks: gitea.yml
@ -22,7 +22,7 @@
loop_control: loop_control:
loop_var: site loop_var: site
when: site.type == "gitea" when: site.type == "gitea"
tags: gitea tags: gitea,sites
- name: Build Synapse sites - name: Build Synapse sites
include_tasks: synapse.yml include_tasks: synapse.yml
@ -30,4 +30,4 @@
loop_control: loop_control:
loop_var: site loop_var: site
when: site.type == "synapse" when: site.type == "synapse"
tags: synapse tags: synapse,sites