我有4本剧本。其中 2 个正在我的目标计算机上部署服务,其中 2 个正在再次删除它们。现在我想把它们放在角色中。但我不确定最佳实践是什么。
2 个部署剧本只是使用不同的变量和模板做完全相同的事情。同样适用于删除剧本。
Atm 我的结构如下所示:
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 任务文件中。