【发布时间】:2019-04-20 07:25:57
【问题描述】:
我想跳过一些基于条件值的播放。 我可以在开始时有一个任务,当满足条件时会跳过其他一些任务。
我知道我总是可以使用set_fact 并将其用作运行其他游戏(角色和任务)的条件,或者在我想跳过的每个游戏中直接评估所述条件。
但是,由于剧本已经有了一个标记系统,我可以利用 Ansible 中的 set_tags 之类的东西来避免在我的剧本中添加条件并使我已经很重的剧本膨胀。
诸如:
- name: skip terraform tasks if no file is provided
hosts: localhost
tasks:
set_tags:
- name: terraform
state: skip
when: terraform_files == ""
我想跳过的两部戏:
- name: bootstrap a testing infrastructure
hosts: localhost
roles:
- role: terraform
state: present
tags:
- create_servers
- terraform
[...]
- name: flush the testing infrastructure
hosts: localhost
roles:
- role: terraform
state: absent
tags:
- destroy_servers
- terraform
【问题讨论】:
标签: ansible