diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a467d..60d64c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 154f8cc..36c09aa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml index 4340cd0..7d28987 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index f29b401..190d94a 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -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 diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 68f5223..e73cc9e 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -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 . diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py index e474363..363d85b 100644 --- a/molecule/default/tests/test_default.py +++ b/molecule/default/tests/test_default.py @@ -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') diff --git a/tasks/main.yml b/tasks/main.yml index 9d5a75d..4375672 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 }}'