ANSIBLE-处理程序侦听

问题描述

真正简短的问题。我只是想知道为什么当我们使用处理程序时,“侦听”部分不带变量?

- name: notify components 
  command: echo "this task will notify all the components"
  notify: "hello world"
- debug:
    msg: "Hello world !!"
  listen: "hello world"

- set_fact:
    myvar: "hello world"
  listen: "hello world"

- debug:
    msg: "Hello world !! with var"
  listen: "{{myvar}}"

为什么此部分不起作用?听不带变量?

解决方法

具体记录在handlers documentation上的注释中

处理程序名称是可模板化的,而侦听主题则不是。