【发布时间】:2021-12-28 06:54:40
【问题描述】:
小上下文:
我清单中的某些主机需要 nginx 访问限制。为了实现这一点,我实现了一个 bool restrict_access: yes,现在我需要重新运行我的 nginx 设置角色。
有没有办法仅匹配将此标志设置为 true 的主机?谢谢!
【问题讨论】:
小上下文:
我清单中的某些主机需要 nginx 访问限制。为了实现这一点,我实现了一个 bool restrict_access: yes,现在我需要重新运行我的 nginx 设置角色。
有没有办法仅匹配将此标志设置为 true 的主机?谢谢!
【问题讨论】:
你可以在任务级别实现它
例如:
# roles/webserver/tasks/main.yml
- import_tasks: configure-nginx.yml
when: restrict_access
- import_tasks: do-not-configure-nginx.yml
when: not restrict_access
【讨论】: