Gitlab-ci 多个图像,每个阶段 before_script 并安装对图像的依赖

Gitlab-ci multiple images, before_script per stage and installing dependency to image

我有一些关于gitlab的问题-ci

  1. 如何使用多张图片?也许每个阶段一张图片或取决于工作名称?
####  How use one image for JobA1 and JobA2  

JobA1:
    stage: Test
    script:
        - ansible-playbook testa1.yml

JobA2:
    stage: Test
    script:
        - ansible-playbook testa2.yml

####  How use other image to JobB1 and JobB2  

JobB1:
    stage: Test
    script:
        - ansible-playbook testa1.yml

JobB2:
    stage: Test
    script:
        - ansible-playbook testa2.yml
  1. 如何使用 before_script 取决于阶段?
  2. 如何安装镜像依赖?我试过这样做
before_script:
- apt update
- apt install software-properties-common
- apt-add-repository --yes --update ppa:ansible/ansible
- apt install ansible

我在日志中看到 before_script 中的命令将会执行,但是在安装 ansible 时必须确认安装 - 我该怎么做?或者,有没有更好的方法来安装 ansible 到图像?

0 upgraded, 73 newly installed, 0 to remove and 12 not upgraded.
Need to get 24.8 MB of archives.
After this operation, 112 MB of additional disk space will be used.
Do you want to continue? [Y/n] Abort.

原来我需要一个安装了 ansible 的 docker 图像。 dockerhub 中没有这样的东西,所以我在安装 Ansible 和 Molecule 的地方创建了我的。你可以使用:)

Ubuntu:18.04 image

Debian:10 image

CentOS:8 image