【问题标题】:Ansible - How to match against hosts with certain bool variable?Ansible - 如何匹配具有某些布尔变量的主机?
【发布时间】:2021-12-28 06:54:40
【问题描述】:

小上下文:

我清单中的某些主机需要 nginx 访问限制。为了实现这一点,我实现了一个 bool restrict_access: yes,现在我需要重新运行我的 nginx 设置角色。

有没有办法匹配将此标志设置为 true 的主机?谢谢!

【问题讨论】:

    标签: ansible ansible-inventory


    【解决方案1】:

    你可以在任务级别实现它

    例如:

    # roles/webserver/tasks/main.yml  
    - import_tasks: configure-nginx.yml
      when: restrict_access
    
    - import_tasks: do-not-configure-nginx.yml
      when: not restrict_access
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      相关资源
      最近更新 更多