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
- feat: add gitlab_registry_url variable
- feat: add options for backup
- test: add support debian 12
### Changed
@ -17,6 +18,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
### Removed
- test: remove support debian 10
- test: remove support debian 11
## 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_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_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

View file

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

View file

@ -5,23 +5,15 @@
- ansible-role-gitlab
vars:
gitlab_data_dir: /opt/data/git
gitlab_backup_auto: false
gitlab_backup_skip:
- db
- registry
gitlab_config:
prometheus:
enable: false
alertmanager:
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:
- name: delete dockerenv file

View file

@ -11,15 +11,6 @@ platforms:
command: /bin/systemd
capabilities:
- 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: |
set -e
yamllint .

View file

@ -18,8 +18,15 @@ def test_config_file(host):
assert config.group == 'root'
assert config.mode == 0o600
assert config.contains("external_url 'http://gitlab.example.com'")
assert config.contains("grafana\\['enable'\\] = false")
assert config.contains('label: Main AD')
assert config.contains("prometheus\\['enable'\\] = false")
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):
service = host.service('gitlab-runsvdir')
@ -41,4 +48,4 @@ def test_cron_file(host):
config = host.file('/var/spool/cron/crontabs/root')
assert config.exists
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
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
ansible.builtin.cron:
name: gitlab-backup
user: root
job: gitlab-backup create
job: "gitlab-backup create SKIP={{ gitlab_backup_skip | join(',') }}"
month: '{{ gitlab_backup_cron_month | string }}'
weekday: '{{ gitlab_backup_cron_weekday | string }}'
day: '{{ gitlab_backup_cron_day | string }}'