最佳實踐要點
- 使用官方 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