如果我想在同一个盒子上部署 gitlab + ansible,我需要 "shell" runner 吗?

Do I need "shell" runner if I want to deploy gitlab + ansible on the same box?

我看过一个关于使用 Infrastructure as code 的 gitlab 演示。如果我想在本地做同样的事情,这行得通吗?设置开源 gitlab on-prem,设置一个 bash 作为 shell runner,并使用 shell runner,在网络设备上执行 ansible playbooks?

写完这个答案后,我现在认为这个问题有被关闭的风险,因为它过于宽泛或主要基于意见;但是,我已经费力打出来了,所以我们开始吧。

Setup open-source gitlab on-prem, setup a bash as shell runner, and using the shell runner, execute ansible playbooks on the network equipment?

我相信这是可能的,或者您可以将 ansible 连同剧本所需的任何 python 模块一起安装到 docker 映像中,然后使用 docker 执行器 运行 容器内的剧本。使用 Tower or AWX is also possible, since they have the concept of projects run from source control

使用 docker 运行ner 的优点是您不必在每个 运行ner 主机上预安装 ansible(及其依赖项);使用 docker 运行ner 的缺点是我可以想象从容器内部进行 ssh 身份验证会变得很奇怪。

# hypothetical .gitlab-ci.yml
stages:
- apply
run ansible playbook:
  stage: apply
  image: docker.example.com/my-ansible:2.8
  scripts:
  - ansible-playbook -i ./some-inventory -v playbook.yml

使用像 AWX(或 Tower)这样的专用系统的优势在于,这些剧本 运行 所针对的清单也是系统中正式管理的实体,并且不需要教 GitLab 如何使其可用于您的剧本。与身份验证相同,因为 AWX 首先 class 支持托管 SSH 密钥对,可以有条件地仅授予某些剧本项目

您仍然可以让 GitLab 与 Tower 集成,方法是使用 tower-cli or their rich API 启动作业模板,该模板的项目配置为在启动前执行 SCM 更新