mirror of
https://gitlab.com/s3lph/ansible-collection-dirvish
synced 2024-12-12 11:01:03 +01:00
Documentation & example
This commit is contained in:
parent
cadfc11ec5
commit
a80f0acb88
10 changed files with 123 additions and 2 deletions
8
.gitlab-ci.yml
Normal file
8
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
image: yokogawa/ansible-lint@sha256:410af7d376066c7f352943e016de78df0b5580b09e63e38440909c30c5fd67b8
|
||||||
|
|
||||||
|
lint:
|
||||||
|
script:
|
||||||
|
- ansible-galaxy install -r requirements.yml
|
||||||
|
- ansible-lint --force-color .
|
12
README.md
12
README.md
|
@ -1,5 +1,13 @@
|
||||||
# Ansible Collection - s3lph.dirvish
|
# Ansible Collection - s3lph.dirvish
|
||||||
|
|
||||||
Documentation for the collection.
|
WIP
|
||||||
|
|
||||||
WIP, TBD
|
## Usage
|
||||||
|
|
||||||
|
1. Use the contents of `docs/` as a template for your playbook directory
|
||||||
|
1. Run `ansible-galaxy install -r requirements.yml`
|
||||||
|
1. Add your backup servers as well as backed-up clients to the inventory
|
||||||
|
- Don't add the clients all at once; instead run the playbook after adding each client and initialize the client
|
||||||
|
1. Add the snapshot scripts required for your services to the `templates/` directory
|
||||||
|
1. Configure the variables in `group_vars/` and `host_vars/`
|
||||||
|
1. TBD ...
|
12
docs/group_vars/dbms/dirvish_client.yml
Normal file
12
docs/group_vars/dbms/dirvish_client.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# List of snapshot scripts to install and include in the snapshot
|
||||||
|
# cronjob Snapshot scripts must be declared as templates, e.g. in the
|
||||||
|
# templates directory.
|
||||||
|
dirvish_client_snapshot_scripts:
|
||||||
|
- mysql-snapshot.sh
|
||||||
|
|
||||||
|
# Exclude the MariaDB data directory, as that's already covered by the snapshot
|
||||||
|
dirvish_server_client_exclude:
|
||||||
|
- 'var/lib/mysql/'
|
||||||
|
|
5
docs/group_vars/servers/dirvish_client.yml
Normal file
5
docs/group_vars/servers/dirvish_client.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# Additionally exclude dirvish vaults when taking backups of other servers
|
||||||
|
dirvish_server_client_exclude:
|
||||||
|
- 'data/'
|
14
docs/group_vars/servers/dirvish_server.yml
Normal file
14
docs/group_vars/servers/dirvish_server.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
# Ensure that these mount points exist before writing any config changes
|
||||||
|
dirvish_server_bank_mounts:
|
||||||
|
- '/data'
|
||||||
|
|
||||||
|
# Exclude the following files/directories on all clients
|
||||||
|
dirvish_server_exclude:
|
||||||
|
- 'lost+found/'
|
||||||
|
- 'dev/'
|
||||||
|
- 'proc/'
|
||||||
|
- 'run/'
|
||||||
|
- 'sys/'
|
||||||
|
- 'tmp/'
|
32
docs/inventory.ini
Normal file
32
docs/inventory.ini
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
[all:children]
|
||||||
|
clients
|
||||||
|
|
||||||
|
# Clients to be backed up
|
||||||
|
[clients:children]
|
||||||
|
lb
|
||||||
|
web
|
||||||
|
db
|
||||||
|
# Backup servers should have backups as well. Just make sure to
|
||||||
|
# exclude the dirvish vaults...
|
||||||
|
servers
|
||||||
|
|
||||||
|
[lb]
|
||||||
|
lb01.example.com
|
||||||
|
lb02.example.com
|
||||||
|
|
||||||
|
[web]
|
||||||
|
web01.example.com
|
||||||
|
web02.example.com
|
||||||
|
web03.example.com
|
||||||
|
|
||||||
|
[dbms]
|
||||||
|
dbms01.example.com
|
||||||
|
dbms02.example.com
|
||||||
|
dbms03.example.com
|
||||||
|
|
||||||
|
# Backup servers
|
||||||
|
[servers]
|
||||||
|
vault01.example.com
|
||||||
|
vault02.example.com
|
||||||
|
vault03.example.com
|
||||||
|
|
10
docs/playbook.yml
Normal file
10
docs/playbook.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- hosts: clients
|
||||||
|
strategy: free
|
||||||
|
roles:
|
||||||
|
- s3lph.dirvish.dirvish_client
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- s3lph.dirvish.dirvish_server
|
5
docs/requirements.yml
Normal file
5
docs/requirements.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
collections:
|
||||||
|
- name: https://gitlab.com/s3lph/ansible-collection-dirvish
|
||||||
|
type: git
|
||||||
|
version: master
|
21
docs/templates/mysql-snapshot.sh.j2
vendored
Normal file
21
docs/templates/mysql-snapshot.sh.j2
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
#
|
||||||
|
# THIS IS AN EXAMPLE
|
||||||
|
# If you want to use this, adapt to your needs and remove the "exit 1"
|
||||||
|
#
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
set -e
|
||||||
|
BACKUPDIR={{ dirvish_client_mysql_backupdir | quote }}
|
||||||
|
MYSQL_BACKUP_CONFIG=/root/.my.cnf
|
||||||
|
|
||||||
|
DATABASES=$(mysql --defaults-extra-file=${MYSQL_BACKUP_CONFIG} --skip-column-names --batch --execute 'SHOW DATABASES')
|
||||||
|
|
||||||
|
for DB in $DATABASES; do
|
||||||
|
if [[ "$DB" == "mysql" || "$DB" == "information_schema" || "$DB" == "performance_schema" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
mysqldump --defaults-extra-file=${MYSQL_BACKUP_CONFIG} --databases "${DB}" | xz > "${BACKUPDIR}/${DB}.xz"
|
||||||
|
done
|
|
@ -34,12 +34,18 @@
|
||||||
file:
|
file:
|
||||||
path: "{{ hostvars[item].dirvish_server_bank }}/{{ item }}/dirvish"
|
path: "{{ hostvars[item].dirvish_server_bank }}/{{ item }}/dirvish"
|
||||||
state: directory
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0755'
|
||||||
loop: "{{ groups[dirvish_server_clients_group] }}"
|
loop: "{{ groups[dirvish_server_clients_group] }}"
|
||||||
|
|
||||||
- name: render all client configs
|
- name: render all client configs
|
||||||
template:
|
template:
|
||||||
src: client_default.conf.j2
|
src: client_default.conf.j2
|
||||||
dest: "{{ hostvars[item].dirvish_server_bank }}/{{ item }}/dirvish/default.conf"
|
dest: "{{ hostvars[item].dirvish_server_bank }}/{{ item }}/dirvish/default.conf"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
loop: "{{ groups[dirvish_server_clients_group] }}"
|
loop: "{{ groups[dirvish_server_clients_group] }}"
|
||||||
|
|
||||||
- name: render dirvish crontab
|
- name: render dirvish crontab
|
||||||
|
|
Loading…
Reference in a new issue