Ansible ERROR:listen不是Ansible任务或处理程序中的合法参数

时间:2018-02-02 12:29:35

标签: ansible

以下是我的代码。

---
- hosts: localhost
  tasks:
  - name: run command
    shell: uname
    register: result
    when: result.stdout== "Linux"
    notify: Create Directory

  handlers:
  - name: create a new new directory
    command: mkdir /home/ubuntu/ansible/new_dir
    listen: Create Directory

运行时出错: 错误:listen不是Ansible任务或处理程序中的合法参数

2 个答案:

答案 0 :(得分:0)

来自docs

  

从Ansible 2.2开始,处理程序也可以“监听”通用主题,任务可以按如下方式通知这些主题......

请升级到Ansible 2.2 +

答案 1 :(得分:0)

notify: Create_Directory

handlers:
      - name: Create_Directory
        file:
          path: /etc/some_directory
          state: directory

notify: Create_Directory并且处理程序的名称应该相等。使用file模块而不是command来创建目录