最佳实践要点
- 使用官方 Docker 镜像
- 使用环境配置的方式更改配置,即在 variables 中更改 ansible.cfg 设置
- Inventory 文件放置在本地,通过 -i 进行指定
样例写法
prod:
stage: deploy
image: ansible/ansible:ubuntu1604
variables:
ANSIBLE_HOST_KEY_CHECKING: "False"
script:
- ansible-playbook -i hosts prod.yml
dependencies:
- build
tags:
- "k8s_runner"
allow_failure: true
when: manual