lean_delivery.gitlab_runner
gitlab-runner 角色
概述
此 Ansible 角色具有以下功能:
- 安装 gitlab-runner
要求
- 安装所需的 ansible 版本:2.8
- 支持的操作系统:
- EL (RedHat, CentOS)
- 7, 8
- Amazon2 Linux
- Ubuntu
- 16.04
- 18.04
- Debian
- 8, 9
- EL (RedHat, CentOS)
角色变量
- 必要的
gitlab_version
Gitlab-Runner 的特定版本。默认值是latest
。gitlab_api_token
访问 Gitlab API 所需的令牌。默认值是''
。gitlab_ci_token
注册 Runner 时获得的令牌。默认值是''
。gitlab_runner_description
Runner 的唯一名称。默认值:
{{ ansible_fqdn }}
{{ ansible_distribution }}
{{ ansible_distribution_major_version }}
默认设置
no_logs
从日志中隐藏敏感信息。默认值是true
。gitlab_runner_skip_registration
安装后跳过 gitlab-runner 注册。默认值是false
。gitlab_host
Docker gitlab 服务器。默认值是gitlab.com
。gitlab_url
Gitlab URL 地址。默认值:https://{{ gitlab_host }}/
。gitlab_runner_tags
与 Runner 关联的标签。应以逗号分隔。默认值是delegated
。gitlab_runner_access_level: not_protected
确定 Runner 是否可以从受保护分支获取作业。可用值:ref_protected
not_protected
默认值是not_protected
。gitlab_runner_untagged_builds_run
配置以防止它选择未标记的作业。默认值是false
。gitlab_runner_lock_to_project
配置将 Runner 锁定到当前项目。默认值是false
。gitlab_runner_executor
Runner 执行器。默认值是shell
。gitlab_runner_extra_options
Runner 注册过程的额外选项。默认值是undefined
。gitlab_runner_limit
限制此令牌可以同时处理的作业数量。0
表示没有限制。默认值是1
。gitlab_runner_concurrent
限制全局可以并发运行的作业数量。 使用所有定义的 Runner 的作业上限。0
并不意味着没有限制。默认值是ansible_processor_vcpus
。gitlab_runner_request_concurrency
限制来自 GitLab 的新作业的并发请求数量。默认值是1
。gitlab_runner_env_vars
附加或覆盖环境变量。默认值是["ENV=value", "LC_ALL=en_US.UTF-8"]
。gitlab_runner_package
Gitlab-runner 包名称。默认:gitlab-runner
。gitlab_runner_packages_additional
为所有安装安装附加包。默认值是[]
。gitlab_runner_gpg
Debian 的 GPG 密钥。默认值是https://packages.gitlab.com/gpg.key
。gitlab_global_section
Gitlab 配置的全局部分。默认是字典:
concurrent: '{{ gitlab_runner_request_concurrency }}' check_interval: 0
gitlab_session_server_section
Gitlab 配置的服务器部分。默认是字典:session_timeout: 1800
gitlab_runners_section
Gitlab 配置的 Runners 部分。默认是字典:
name: '{{ gitlab_runner_description }}' url: '{{ gitlab_url }}' token: '{{ gitlab_runner.runner.token | default(omit) }}' executor: '{{ gitlab_runner_executor }}' environment: '{{ gitlab_runner_env_vars }}'
高级配置
gitlab_runner_config
用于高级配置的字典:params
注册过程中使用的环境变量。global_values
用于在文件 "config.toml" 中添加/更改 非字符串值 的字典。global_strings
用于在文件 "config.toml" 中添加/更改 字符串值 的字典。
附加变量
yum_libselinux_python_library
Selinux Python 库名称。默认值:libselinux-python
。 对于 RedHat 8 或 Fedora,库名称可能不同,例如python3-libselinux
。yum_libselinux_config_libraries
Selinux 配置库。默认值是列表:[policycoreutils-python, libsemanage-python]
。 对于 RedHat 8 或 Fedora,值可能不同:- python3-policycoreutils
- python3-libsemanage
epel_repository_url
EPEL repo 包的 URL。默认:https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
epel_rpm_key
EPEL rpm 密钥。默认值:/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}
gitlab_runner_python_module_version
python-gitlab 库版本。默认:'1.12.1'
。pip_executable
pip 可执行二进制文件的名称。默认:pip
适用于基于 RedHat 的目标pip3
适用于基于 Debian 的目标
python_executable
python 可执行文件的名称。默认:python
适用于基于 RedHat 的目标python3
适用于基于 Debian 的目标
安装当前角色的一些示例
使用 playlabs 你可以只需一个命令安装此角色,例如:
playlabs install lean_delivery.gitlab_runner @localhost gitlab_ci_token=yourcommand gitlab_host=yourlabs.io gitlab_runner_limit=4 gitlab_version=11.6
或者,如果没有 playlabs,可以使用 galaxy 来安装,以便在你的 playbook 中使用:
ansible-galaxy install lean_delivery.gitlab_runner
示例 Playbook
安装 gitlab-runner 不进行注册:
- name: Converge
hosts: gitlab_runner
roles:
- role: lean_delivery.gitlab_runner
vars:
gitlab_runner_concurrent: 1
gitlab_runner_skip_registration: true
安装 gitlab-runner 并进行注册和配置:
- name: Converge
hosts: gitlab_runner
roles:
- role: lean_delivery.gitlab_runner
gitlab_runner_concurrent: 4
gitlab_runner_skip_registration: false
gitlab_api_token: >-
{{ lookup('env', 'GITLAB_API_TOKEN') }}
gitlab_ci_token: >-
{{ lookup('env', 'GITLAB_REGISTRATION_TOKEN') }}
gitlab_runner_description: 'My Great Runner'
gitlab_runner_tags:
- deploy_test
- shell
gitlab_runner_untagged_builds_run: false
gitlab_runner_concurrent: 1
gitlab_version: '12.5.1'
gitlab_runner_skip_registration: false
许可证
Apache
作者信息
作者:
- Lean Delivery 团队 team@lean-delivery.com
关于项目
Lean Delivery Gitlab Runner install
安装
ansible-galaxy install lean_delivery.gitlab_runner
许可证
apache-2.0
下载
43.2k
拥有者
Simplify by using!