我有一个这样的剧本,每个客户都有一个角色。
- hosts: hosting
roles:
- { role: client1, tags: ['client1'] }
- { role: client2, tags: ['client2'] }
在每个角色上,我都依赖于nginx。
/roles/client1/meta/main.yml
dependencies:
- nginx
如果没有必要,我想不启动 nginx角色。所以我已经将nginx标签添加到依赖项中。
/roles/client1/meta/main.yml
dependencies:
- { role: nginx, tags: ['system'] }
但是当我用标签client1启动playbook时,会执行nginx角色。 有没有解决方案来避免这种情况?
我知道可以"导出"对剧本的依赖,它运作良好,但我认为这不是一个好的解决方案。
- hosts: hosting
roles:
- { role: nginx, tags: ['system'] }
- { role: client1, tags: ['client1'] }
- { role: client2, tags: ['client2'] }
答案 0 :(得分:6)
标签不会互相覆盖,但具有累积性。您的相关性现在具有标记client1
和system
。
但这已经足够了。告诉Ansible在调用你的剧本时跳过系统标签:
ansible-playbook ... --tags client1 --skip-tags system