【问题标题】:ansible. Run handler on specific host可靠的。在特定主机上运行处理程序
【发布时间】:2019-07-05 14:15:02
【问题描述】:

我需要在ansible运行期间收集一些信息并最终打印这些信息。

我尝试在角色中定义空列表变量。我在剧本处理程序中添加了新值,以在剧本末尾列出该变量的蚂蚁打印值。

  set_fact:
    manual_tasks: "{{ manual_tasks + ['restart apache'] }}"

我想念与 set_fact 主机相关的内容。因此,一旦我开始使用不同的主机,这个解决方案就会停止工作。 Delegate_to 也不能解决问题。有没有办法让这个列表全球化?还是有其他解决方案?

【问题讨论】:

    标签: ansible ansible-handlers


    【解决方案1】:

    问:Add new value to list and print it at the end of the playbook. Is there way to make this list global?

    A:不,不是。 “Global 范围由配置、环境变量和命令行设置。”主机不能在播放或全局范围内set_fact

    您可能想看看ansible-runner。见Sending Runner Status and Events to External Systems

    【讨论】:

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