-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial re-drafting variables to support backup configuration for gitlab v12.1+, parameterizing the backup schedule to allow for greater flexibility * Temporarily disabling the installation of cron to debug values * Resolving template issues for gitlab configuration backups * Adding customizable environment variable configuration for GitLab Application Backup Cron tasks * Fixing up templating for ansible-role * Cleaning up the filtering process for gitlab_config_backup_env_vars * Correcting backup command debugging message * Adding backup:restore commands for debugging * Finalizing tasks/restore.yml and including gitlab_config_privilege_escalation_user to parameterize become_user for ansible-role * Cleaning up vars/main.tf * Removing debugging message block * Adding dependent roles and debugging andrewrothstein.gitlab vars * Dropping gitlab_ver definition * Cleaning up main/task.yml * Parameterize the letsencrypt operation for omnibus-gitlab in test domain on vSphere-Lab * Convert ansible_bool variable to JSON compatible value
- Loading branch information
Showing
8 changed files
with
207 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,66 @@ | ||
--- | ||
- name: create backup dir | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
when: gitlab_config_manage_backup_path or gitlab_config_backup_use_nfs | ||
file: | ||
path: '{{ gitlab_config_backup_dir }}' | ||
state: directory | ||
mode: 0755 | ||
owner: '{{ gitlab_config_eff_user }}' | ||
group: '{{ gitlab_config_eff_group }}' | ||
|
||
- name: create cronjob to take nightly backup of application data | ||
become: yes | ||
become_user: root | ||
when: gitlab_config_backup_application_data|default(true) | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
when: gitlab_config_backup_application_data | ||
cron: | ||
name: "gitlab-ce-nightly-backups-app-data" | ||
minute: "0" | ||
hour: "2" | ||
job: "/opt/gitlab/bin/gitlab-rake gitlab:backup:create" | ||
name: "gitlab-app-data-backup" | ||
job: |- | ||
{{ gitlab_config_backup_program }} {{ gitlab_config_backup_command }} | ||
{%- for env in (gitlab_config_backup_environment_vars | dict2items | rejectattr("value", "eq", "") | list) %} {{ env.key }}={{ env.value }}{% endfor -%} | ||
month: '{{ gitlab_config_backup_application_data_schedule.month | default(omit) }}' | ||
weekday: '{{ gitlab_config_backup_application_data_schedule.weekday | default(omit) }}' | ||
day: '{{ gitlab_config_backup_application_data_schedule.day | default(omit) }}' | ||
hour: '{{ gitlab_config_backup_application_data_schedule.hour | default(omit) }}' | ||
minute: '{{ gitlab_config_backup_application_data_schedule.minute | default(omit) }}' | ||
state: present | ||
|
||
- name: create cronjob to take nightly backup of configuration data | ||
become: yes | ||
become_user: root | ||
when: gitlab_config_backup_config_data|default(true) | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
when: gitlab_config_backup_config_data | ||
cron: | ||
name: "gitlab-ce-nightly-backups-config-data" | ||
minute: "0" | ||
hour: "2" | ||
job: 'umask 0077; FILE=$(date "+etc-gitlab-\%s.tgz"); tar cfz {{ gitlab_config_auto_nightly_backup_config_data_path }}/$FILE -C / etc/gitlab; {{ gitlab_config_backup_config_data_additional_cmd }}' | ||
name: "gitlab-config-data-backup" | ||
job: |- | ||
{{ ((gitlab_ver is version("12.3", operator="<") | ternary( | ||
[ | ||
"umask %s" | format(gitlab_config_auto_backup_config_data_permissions), | ||
'FILE=$(date "+etc-gitlab-\%s.tgz")', | ||
"tar cfz %s/$FILE -C / %s" | format(gitlab_config_auto_backup_config_data_path, gitlab_config_dest) | ||
], | ||
[ | ||
"%s backup-etc %s" | format(gitlab_config_controller_cli, gitlab_config_auto_backup_config_data_path) | ||
])) + (gitlab_config_backup_config_data_addl_cmds | default([]))) | join(";") }} | ||
month: '{{ gitlab_config_backup_config_data_schedule.month | default(omit) }}' | ||
weekday: '{{ gitlab_config_backup_config_data_schedule.weekday | default(omit) }}' | ||
day: '{{ gitlab_config_backup_config_data_schedule.day | default(omit) }}' | ||
hour: '{{ gitlab_config_backup_config_data_schedule.hour | default(omit) }}' | ||
minute: '{{ gitlab_config_backup_config_data_schedule.minute | default(omit) }}' | ||
state: present | ||
|
||
- name: update MAILTO entry of crontab to get output of nightly jobs | ||
become: yes | ||
become_user: root | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
when: gitlab_config_cronjob_notification_email is defined | ||
cronvar: | ||
name: MAILTO | ||
value: "{{ gitlab_config_cronjob_notification_email }}" | ||
value: '{{ gitlab_config_cronjob_notification_email }}' | ||
|
||
- name: update MAILFROM entry of crontab | ||
become: yes | ||
become_user: root | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
when: gitlab_config_cronjob_notification_email is defined and gitlab_config_email_from is defined | ||
cronvar: | ||
name: MAILFROM | ||
value: "{{ gitlab_config_email_from }}" | ||
value: '{{ gitlab_config_email_from }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,25 @@ | ||
--- | ||
- include_tasks: pki.yml | ||
when: gitlab_config_enable_https|default(false) | ||
|
||
- name: create backup dir | ||
become: yes | ||
become_user: root | ||
when: gitlab_config_manage_backup_path|default(false) or gitlab_config_backup_use_nfs|default(false) | ||
file: | ||
path: '{{ gitlab_config_backup_dir }}' | ||
state: directory | ||
mode: 0755 | ||
owner: git | ||
group: git | ||
|
||
- name: load gitlab-config file | ||
become: yes | ||
become_user: root | ||
register: load_config | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
register: gitlab_config | ||
template: | ||
src: gitlab.rb.j2 | ||
dest: '{{ gitlab_config_dest }}/gitlab.rb' | ||
mode: 0600 | ||
|
||
- name: reconfigure gitlab | ||
become: yes | ||
become_user: root | ||
when: gitlab_config_reconfigure|default(true) and load_config is changed | ||
command: gitlab-ctl reconfigure | ||
- include_tasks: pki.yml | ||
when: gitlab_config_enable_https | ||
|
||
- include_tasks: backup.yml | ||
when: gitlab_config_auto_nightly_backup | default(true) | ||
when: gitlab_config_auto_backup_enabled | ||
|
||
- name: reconfigure gitlab | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
when: gitlab_config_reconfigure and gitlab_config is changed | ||
command: '{{ gitlab_config_controller_cli }} reconfigure' | ||
|
||
- name: restore gitlab | ||
when: gitlab_config_backup_restore_enabled | ||
include_tasks: restore.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
- name: stop processes connected to database | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
loop: | ||
- unicorn | ||
- puma | ||
- sidekiq | ||
command: '{{ gitlab_config_controller_cli }} stop {{ item }}' | ||
|
||
- name: restore application backup ref={{ gitlab_config_backup_restore_timestamp }} | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
command: |- | ||
{{ gitlab_config_backup_program }} {{ gitlab_config_backup_restore_command }} | ||
{%- for k,v in gitlab_config_backup_restore_environment_vars.items() %} {{ k }}={{ v }}{% endfor -%} | ||
- name: look for gitlab secrets file | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
changed_when: False | ||
stat: | ||
path: '{{ gitlab_config_secrets_path }}' | ||
register: gitlab_secrets | ||
|
||
- when: gitlab_secrets.stat.exists | ||
become: '{{ gitlab_config_privilege_escalate }}' | ||
become_user: '{{ gitlab_config_privilege_escalation_user }}' | ||
block: | ||
- name: reload gitlab | ||
loop: | ||
- reconfigure | ||
- restart | ||
command: '{{ gitlab_config_controller_cli }} {{ item }}' | ||
|
||
- name: check gitlab configuration | ||
when: gitlab_config_backup_restore_check_config | ||
command: gitlab-rake gitlab:check SANITIZE=true | ||
|
||
- name: verify db decryption capabilities | ||
when: gitlab_config_backup_restore_verify_db_secrets | ||
command: gitlab-rake gitlab:doctor:secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters