hifis.gitlab
GitLab Ansible 角色
:warning: 该项目已归档! :warning:
该角色已迁移到我们的 hifis.toolkit
集合中:
- https://github.com/hifis-net/ansible-collection-toolkit
- https://galaxy.ansible.com/ui/repo/published/hifis/toolkit/
一个用于安装和配置官方 GitLab Omnibus 包的角色。
当前支持的平台包括:
- CentOS 7
- AlmaLinux 8
- Debian 11 (Bullseye)
- Ubuntu 18.04 LTS (Bionic Beaver)
- Ubuntu 20.04 LTS (Focal Fossa)
- Ubuntu 22.04 LTS (Jemmy Jellyfish)
要求
无。
角色变量
重要角色变量
GitLab 版本
要安装的 GitLab 版本。请使用 gitlab-ce
表示社区版或 gitlab-ee
表示企业版。
gitlab_edition: "gitlab-ee"
GitLab 版本和发行版
设置要安装的特定 GitLab 版本。请确保还指定所需的发行版。可在这里找到可用的发行版。
gitlab_version: "15.6.1"
# RHEL/AlmaLinux 8 的 GitLab 发行版
gitlab_release: "ce.0.el8"
# Ubuntu 的 GitLab 发行版
gitlab_release: "ce.0"
请注意: 如果未指定 GitLab 版本,该角色将始终安装最新可用的 GitLab 包。
GPG 密钥 URL
用于签署软件包的 GPG 密钥的 URL。
gitlab_gpg_key_url: "https://packages.gitlab.com/gitlab/{{ gitlab_edition }}/gpgkey"
GPG 密钥 ID
用于签署软件包的 GPG 密钥的标识符。
gitlab_gpg_key_id: "F6403F6544A38863DAA0B6E03F01618A51312F3F"
软件包仓库 URL
基于操作系统的软件包仓库的 URL。
gitlab_repo_url: "https://packages.gitlab.com/gitlab/{{ gitlab_edition }}/ubuntu/"
源软件包仓库 URL
源软件包仓库的 URL(仅限 CentOS 和 AlmaLinux)。
gitlab_source_repo_url: "https://packages.gitlab.com/gitlab/{{ gitlab_edition }}/el/{{ ansible_facts.distribution_major_version }}/SRPMS"
软件包名称
要安装的 GitLab 软件包的名称。
gitlab_package_name: "{{ gitlab_edition + '=' + gitlab_version + '-' + gitlab_release if gitlab_version and gitlab_release else gitlab_edition }}"
软件包依赖
GitLab 所需的依赖软件包列表,基于操作系统。
gitlab_dependencies:
- apt-transport-https
- curl
- gnupg
- openssh-server
- openssl
- tzdata
GitLab 实例的 URL
提供你的 GitLab 实例的 URL:
gitlab_external_url: 'https://gitlab.example.com'
GitLab 使用的时区
选择 GitLab 使用的时区:
gitlab_time_zone: 'Europe/Berlin'
保留备份的时间周期
设置 GitLab 备份的保留时间(以秒为单位):
gitlab_backup_keep_time: '604800'
可选角色变量
GitLab 配置文件的模板名称
指定将转换为 GitLab 配置文件的模板名称:
gitlab_configuration_file_template: 'gitlab.rb.j2'
GitLab 配置文件的路径
指定包含 GitLab 实例自定义配置的配置文件模板的路径:
gitlab_configuration_file_path: '/etc/gitlab/gitlab.rb'
默认使用的 GitLab 主题
选择新 GitLab 用户的默认主题:
gitlab_default_theme: '2'
GitLab 备份的路径
设置 GitLab 备份的路径:
gitlab_backup_path: '/var/opt/gitlab/backups'
Web 服务器 Nginx 监听的端口
设置 GitLab 的 Web 服务器 Nginx 监听的端口:
gitlab_nginx_listen_port: '80'
Web 服务器 Nginx 是否接受 HTTPS 请求?
选择 GitLab 的 Web 服务器 Nginx 是否接受 HTTPS 请求:
gitlab_nginx_listen_https: 'false'
Web 服务器 Nginx 是否将 HTTP 请求重定向到 HTTPS?
选择 GitLab 的 Web 服务器 Nginx 是否将 HTTP 请求重定向到 HTTPS:
gitlab_nginx_redirect_http_to_https: 'false'
设置 GitLab 功能标志
设置 GitLab 功能标志 以启用或禁用附加功能。
该变量是一个键值对列表,要求指定功能标志的 name
和其布尔状态 enabled
。
默认值设置为空列表 []
。
gitlab_feature_flags:
- name: "vscode_web_ide"
enabled: true
- name: "chatops"
enabled: true
- name: "webauthn"
enabled: false
仅使用 Mattermost 的用例
此角色可用于运行 Mattermost,而不部署 GitLab。在此方案中,不需要像 sidekiq 或 puma 等服务。设置为 true
以防止角色重新加载这些服务:
gitlab_mattermost_only_context: 'false'
使用外部 Redis 时需设置的变量
切换到使用外部 Redis 实例
设置开关为 false
以启用外部 Redis 实例:
gitlab_use_internal_redis: 'false'
用于在集群中认证 Redis 服务的密码
建议通过提供相应的密码为 Redis 主服务器和 Redis 副本启用认证:
gitlab_redis_password: 'changeme'
注意:你必须在此处使用自己的私有和加密密码。
认证 Redis Sentinel 的密码
在 GitLab 16.1 中引入了 Redis Sentinel 密码认证支持。
gitlab_redis_sentinel_password: 'changeme'
注意:你必须在此处使用自己的私有和加密密码。
Redis 集群的引用名称
选择一个 Redis 集群的名称以供参考:
gitlab_redis_cluster_name: 'redis-cluster'
Redis Sentinel 服务器的 IP 地址列表
添加参与的 Redis Sentinel 服务器的 IP 地址列表:
gitlab_redis_sentinel_ips:
- '192.168.33.11'
- '192.168.33.12'
- '192.168.33.13'
Redis Sentinel 服务器监听的端口
选择 Redis Sentinel 服务器监听的端口:
gitlab_redis_sentinel_port: '26379'
GitLab 监控 Redis Sentinel 服务器的 IP 地址范围
允许监控 Redis Sentinel 服务器的 GitLab IP 地址范围:
gitlab_ip_range: '{{ ansible_facts.default_ipv4.address }}/24'
使用外部 Gitaly 时需设置的变量
切换到使用外部 Gitaly 实例
设置开关为 false
以启用外部 Gitaly 实例:
gitlab_use_internal_gitaly: 'false'
GitLab 数据目录的路径
指定 GitLab 数据目录的存放位置:
gitlab_git_data_dir: "/var/opt/gitlab/git-data"
Gitaly 认证令牌
需要提供 Gitaly 认证令牌:
gitlab_gitaly_token: 'changeme'
注意:你必须在此处使用自己的私有和加密密码。
GitLab Shell 令牌
需要提供 GitLab shell 令牌:
gitlab_secret_token: 'changeme'
注意:你必须在此处使用自己的私有和加密密码。
Gitaly 的 IP 地址
指定 Gitaly 实例的 IP 地址:
gitlab_gitaly_instance_ip: '127.0.0.1'
Gitaly 端口
指定 Gitaly 实例的端口:
gitlab_gitaly_instance_port: '8075'
使用外部 PostgreSQL 数据库时需设置的变量
切换到使用外部 PostgreSQL 数据库实例
设置开关为 false
以启用外部 PostgreSQL 数据库实例:
gitlab_use_internal_postgresql: 'false'
外部 PostgreSQL 数据库实例的 IP 地址
设置 PostgreSQL 数据库实例的 IP 地址:
gitlab_postgresql_db_host: '127.0.0.1'
外部 PostgreSQL 数据库实例的密码
设置 PostgreSQL 数据库实例的密码:
gitlab_postgresql_db_password: 'changeme'
注意:你必须在此处使用自己的私有和加密密码。
配置 GitLab 注册表
启用 GitLab 容器注册表:
gitlab_registry_enable: "true"
_请注意_:如果你没有在 GitLab 前面运行负载均衡器并让 Nginx 处理 SSL 加密,请通过 gitlab_additional_configurations
也配置 registry_nginx['ssl_certificate']
和 registry_nginx['ssl_certificate_key']
。
作为角色变量的其他配置
任何尚不包含在 GitLab 配置文件中的其他配置都可以通过 Ansible 角色变量给出。
通过类似字典的 Ruby 变量进行配置
不属于 GitLab 配置文件的 Ruby 变量可以通过 Ansible 角色变量给出。
代码归属/使用条款:
这一泛型键值对的想法归功于 Jeff Geerling 的工作,该工作最初在 MIT 许可下发布。
使用示例:
gitlab_additional_configurations:
- gitlab_rails:
- key: "time_zone"
value: "Europe/Berlin"
- nginx:
- key: "listen_port"
type: "plain"
value: "80"
- key: "listen_https"
type: "plain"
value: "false"
生成的配置:
gitlab_rails['time_zone'] = 'Europe/Berlin'
nginx['listen_port'] = 80
nginx['listen_https'] = false
通过 Ruby 函数调用进行配置
不属于 GitLab 配置文件的 Ruby 函数调用可以通过 Ansible 角色变量给出。
使用示例:
gitlab_ruby_configuration_calls:
- key: "pages_external_url"
value: "https://pages.example.com"
- key: "registry_external_url"
value: "https://registry.example.com"
- key: "mattermost_external_url"
value: "https://mattermost.example.com"
生成的配置:
registry_external_url "https://registry.example.com"
pages_external_url "https://pages.example.com"
mattermost_external_url "https://mattermost.example.com"
依赖项
无。
许可
作者信息
贡献者
我们想对以下贡献者表示感谢和致敬: