Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们最近将 Ansible 部署与 Jenkins 集成。一切看起来都很好,下一步是找到一种方法来存储所有剧本变量。最好的做法是什么?我们希望为每个环境(Dev、QA、UAT、Prod)设置不同的变量集。非常感谢。
使用 shell/批处理脚本并将它们设置为环境变量。喜欢
#!/bin/bash export var1=value1 export var2=value2
然后在运行 playbook 之前执行脚本。
source <script>.sh bash <script>.sh
您还可以参数化可以在运行时通过 jenkins 传递的值。即
export var1=$1 and so on.....