feat: add options for backup
All checks were successful
/ lint (push) Successful in 15s
/ molecule (push) Successful in 6m20s

This commit is contained in:
Adrien Waksberg 2024-07-11 11:12:29 +02:00
parent cdf5f3090a
commit 2da9b5cfba
7 changed files with 37 additions and 25 deletions

View file

@ -8,6 +8,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Added ### Added
- feat: add gitlab_registry_url variable - feat: add gitlab_registry_url variable
- feat: add options for backup
- test: add support debian 12 - test: add support debian 12
### Changed ### Changed
@ -17,6 +18,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Removed ### Removed
- test: remove support debian 10 - test: remove support debian 10
- test: remove support debian 11
## v1.1.0 - 2021-08-24 ## v1.1.0 - 2021-08-24

View file

@ -33,6 +33,8 @@ Install and configure a Gitlab server
- `gitlab_backup_cron_day` - set the day for the backup cron (default: `'*'`) - `gitlab_backup_cron_day` - set the day for the backup cron (default: `'*'`)
- `gitlab_backup_cron_hour` - set the hour for the backup cron (default: `2`) - `gitlab_backup_cron_hour` - set the hour for the backup cron (default: `2`)
- `gitlab_backup_cron_minute` - set the minute for the backup cron (default: `30`) - `gitlab_backup_cron_minute` - set the minute for the backup cron (default: `30`)
- `gitlab_backup_skip` - list with [skip data](https://docs.gitlab.com/ee/administration/backup_restore/backup_gitlab.html#excluding-specific-data-from-the-backup)
- `gitlab_backup_auto` - set if a backup if create during update (default: `true`)
## How to use ## How to use

View file

@ -7,3 +7,5 @@ gitlab_backup_cron_weekday: '*'
gitlab_backup_cron_day: '*' gitlab_backup_cron_day: '*'
gitlab_backup_cron_hour: 2 gitlab_backup_cron_hour: 2
gitlab_backup_cron_minute: 30 gitlab_backup_cron_minute: 30
gitlab_backup_skip: []
gitlab_backup_auto: true

View file

@ -5,23 +5,15 @@
- ansible-role-gitlab - ansible-role-gitlab
vars: vars:
gitlab_data_dir: /opt/data/git gitlab_data_dir: /opt/data/git
gitlab_backup_auto: false
gitlab_backup_skip:
- db
- registry
gitlab_config: gitlab_config:
prometheus: prometheus:
enable: false enable: false
alertmanager: alertmanager:
enable: false enable: false
grafana:
enable: false
ldap_servers:
main:
label: Main AD
host: localhost
port: 389
uid: sAMAccountName
encryption: plain
bind_dn: 'CN=gitlab,DC=example,DC=com'
password: secret
base: 'OU=FR,DC=example,DC=com'
pre_tasks: pre_tasks:
- name: delete dockerenv file - name: delete dockerenv file

View file

@ -11,15 +11,6 @@ platforms:
command: /bin/systemd command: /bin/systemd
capabilities: capabilities:
- SYS_ADMIN - SYS_ADMIN
- name: debian11
image: code.waks.be/nishiki/molecule:debian11
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
cgroupns_mode: host
command: /bin/systemd
capabilities:
- SYS_ADMIN
lint: | lint: |
set -e set -e
yamllint . yamllint .

View file

@ -18,8 +18,15 @@ def test_config_file(host):
assert config.group == 'root' assert config.group == 'root'
assert config.mode == 0o600 assert config.mode == 0o600
assert config.contains("external_url 'http://gitlab.example.com'") assert config.contains("external_url 'http://gitlab.example.com'")
assert config.contains("grafana\\['enable'\\] = false") assert config.contains("prometheus\\['enable'\\] = false")
assert config.contains('label: Main AD')
def test_skip_auto_backup_file(host):
config = host.file('/etc/gitlab/skip-auto-backup')
assert config.exists
assert config.is_file
assert config.user == 'root'
assert config.group == 'root'
assert config.mode == 0o644
def test_service(host): def test_service(host):
service = host.service('gitlab-runsvdir') service = host.service('gitlab-runsvdir')
@ -41,4 +48,4 @@ def test_cron_file(host):
config = host.file('/var/spool/cron/crontabs/root') config = host.file('/var/spool/cron/crontabs/root')
assert config.exists assert config.exists
assert config.is_file assert config.is_file
assert config.contains('30 2 \\* \\* \\* gitlab-backup create') assert config.contains('30 2 \\* \\* \\* gitlab-backup create SKIP=db,registry')

View file

@ -45,11 +45,27 @@
enabled: true enabled: true
tags: gitlab tags: gitlab
- name: Check if skip autobackup file exists
ansible.builtin.stat:
path: /etc/gitlab/skip-auto-backup
register: st
tags: gitlab
- name: Manage skip autobackup file
ansible.builtin.file:
path: /etc/gitlab/skip-auto-backup
owner: root
group: root
mode: "0644"
state: "{{ gitlab_backup_auto | ternary('absent', 'touch')}}"
when: not st.stat.exists or gitlab_backup_auto
tags: gitlab
- name: Add backup cron - name: Add backup cron
ansible.builtin.cron: ansible.builtin.cron:
name: gitlab-backup name: gitlab-backup
user: root user: root
job: gitlab-backup create job: "gitlab-backup create SKIP={{ gitlab_backup_skip | join(',') }}"
month: '{{ gitlab_backup_cron_month | string }}' month: '{{ gitlab_backup_cron_month | string }}'
weekday: '{{ gitlab_backup_cron_weekday | string }}' weekday: '{{ gitlab_backup_cron_weekday | string }}'
day: '{{ gitlab_backup_cron_day | string }}' day: '{{ gitlab_backup_cron_day | string }}'