我有4个剧本。其中2个正在我的目标机器上部署服务,其中2个正在重新删除它们。 现在我想把他们放在角色中。但我不确定最佳做法是什么。
2部署剧本只用不同的变量和模板做同样的事情。这同样适用于删除剧本。Ansible:角色的任务结构
大气压我的结构是这样的:
ansible.cfg
ssh_key
inventoryfile
group_vars
....
roles
deployservicegroupA
vars
...
templates
...
tasks
main.yml (this file simply includes the two tasks right below)
copy-service-templates.yml
start-services.yml
deployservicegroupB
vars
...
templates
...
tasks
main.yml (this file simply includes the two tasks right below)
copy-service-templates.yml
start-services.yml
removeservicegroupA
vars
...
templates
...
tasks
main.yml (this file simply includes the two tasks right below)
remove-services.yml
cleanup.yml
removeservicegroupB
vars
...
templates
...
tasks
main.yml (this file simply includes the two tasks right below)
remove-services.yml
cleanup.yml
这是他们的方式它的目的是通过用户做些什么呢?
我特别想知道我的任务完成同样的事情,但可以在不同的角色中找到。而且如果我应该将我的任务包含在main.yml任务文件中。
您是否在不同组或单个组上运行角色(部署或删除)? – shaps
每个服务都有一个组来指定应该在哪些机器上部署它们。 – Forivin