如何跳过某些服务器的 ansible 角色

问题描述 投票:0回答:1

我有以下代码,其中我有以下 3 个角色。我不想为组名称为“er”的主机执行“def”角色。因此,当服务器也属于“er”组时,请跳过 def 角色。

hosts: qw
vars:
roles:
  abc
  def
  fgh

ansible ansible-2.x ansible-inventory
1个回答
0
投票

您可以使用条件与角色

- hosts: qw
  vars:
  roles:
    - role: abc
    - role: def
      when: 'er' not in group_names
    - role: fgh

类似的东西可能适合您的用例。

© www.soinside.com 2019 - 2024. All rights reserved.