我有以下代码,其中我有以下 3 个角色。我不想为组名称为“er”的主机执行“def”角色。因此,当服务器也属于“er”组时,请跳过 def 角色。
hosts: qw
vars:
roles:
abc
def
fgh
您可以使用条件与角色
- hosts: qw
vars:
roles:
- role: abc
- role: def
when: 'er' not in group_names
- role: fgh
类似的东西可能适合您的用例。