add gitlab role

This commit is contained in:
aaron
2021-08-24 12:16:11 +02:00
commit 80cf4f9a51
11 changed files with 419 additions and 0 deletions

43
tasks/configure.yml Normal file
View File

@@ -0,0 +1,43 @@
---
# vim: ts=2 sw=2 et ft=yaml.ansible
- name: copy gitlab configuration file
template:
src: '{{ gitlab_config_template }}'
dest: '{{ gitlab_config_file }}'
owner: root
group: root
mode: 0600
notify: reconfigure gitlab
no_log: true # do not expose potential secrets
- name: copy gitlab secrets file
template:
src: gitlab-secrets.json.j2
dest: /etc/gitlab/gitlab-secrets.json
owner: root
group: root
mode: 0600
notify: reconfigure gitlab
no_log: true # do not expose potential secrets
- name: copy license when installing gitlab-ee version
template:
src: '{{ gitlab_ee_license_template }}'
dest: '{{ gitlab_ee_license_file }}'
owner: root
group: root
mode: 0644
notify: reconfigure gitlab
no_log: true # do not expose potential secrets
when: gitlab_edition == 'gitlab-ee' and gitlab_ee_license | length > 0
- name: copy ssh host keys when migrating
copy:
dest: '{{ item.key }}'
content: "{{ item.value }}\n"
owner: root
group: root
mode: 0400
loop: '{{ gitlab_ssh_host_keys | dict2items }}'
when: gitlab_import_ssh_host_keys

32
tasks/install.yml Normal file
View File

@@ -0,0 +1,32 @@
---
# vim: ts=2 sw=2 et ft=yaml.ansible
- name: check if gitlab is already installed
stat:
path: '{{ gitlab_ctl_binary }}'
register: gl_binary
- name: install gitlab dependencies
package:
name: '{{ gitlab_pkg_dependencies }}'
state: present
- name: add gitlab repository if necessary
template:
src: '{{ gitlab_install_custom_repo }}'
dest: '/etc/yum.repos.d/gitlab_{{ gitlab_edition }}.repo'
owner: root
group: root
mode: 0644
when: gitlab_install_custom_repo
- name: assemble gitlab package name
set_fact:
gitlab_package: '{{ gitlab_edition }}{{ gitlab_package_version_separator }}{{ gitlab_version }}'
when: gitlab_version | length > 0
- name: install gitlab
package:
name: '{{ gitlab_package | default(gitlab_edition) }}'
state: present
when: not gl_binary.stat.exists

19
tasks/main.yml Normal file
View File

@@ -0,0 +1,19 @@
---
# vim: ts=2 sw=2 et ft=yaml.ansible
- name: load gitlab package dependency list based on distribution type
include_vars: '{{ item }}'
loop:
- 'gitlab_pkg_dependencies.yml'
tags:
- 'gitlab_vars'
- name: install gitlab and dependencies
import_tasks: install.yml
tags:
- 'gitlab_install'
- name: configure gitlab
import_tasks: configure.yml
tags:
- 'gitlab_configure'