Ansible notify handler doen';不执行

Ansible notify handler doen';不执行,ansible,ansible-playbook,Ansible,Ansible Playbook,好的,这是我的任务: --- - name: copy source list copy: src=sources.list dest=/etc/apt/sources.list notify: update apt # - name: Update apt # shell: apt-get update - name: Install postgres shell: apt-get install -q -y postgresql-9.1 #apt: name=post

好的,这是我的任务:

---
- name: copy source list
  copy: src=sources.list dest=/etc/apt/sources.list
  notify: update apt

# - name: Update apt
#   shell: apt-get update

- name: Install postgres
  shell: apt-get install -q -y postgresql-9.1
  #apt: name=postgresql-9.1  state=present 

- others tasks... 
这是我的处理程序:

- name: update apt
  action: apt-get update
当我运行时,它不会通知

...

TASK: [postgresql | copy source list] ***************************************** 
changed: [host_slave2]
changed: [host_slave1]
changed: [host_pgpool]
changed: [host_master]

TASK: [postgresql | Install postgres] ***************************************** 
changed: [host_slave1]
changed: [host_master]
changed: [host_slave2]
changed: [host_pgpool]

...
复印后,我必须查看通知,有什么问题吗?

事实上,这个问题是必须强制执行的

---
- name: copy source list
  copy: src=sources.list dest=/etc/apt/sources.list
  notify: update apt

- meta: flush_handlers


- name: Install postgres
  shell: apt-get install -q -y postgresql-9.1
  #apt: name=postgresql-9.1  state=present 

- others tasks... 

handler:

- name: update apt
  action: apt-get update

notify在运行的最后一刻出现-您是否取消或让它运行到最后?我建议你也多说些废话。最后,这些都很好。虽然建议的答案会起作用,但它并没有像原来的问题那样使用ansible处理程序。
---

- name: copy source list
  copy: src=sources.list dest=/etc/apt/sources.list
#http://docs.ansible.com/apt_repository_module.html
  register: update_apt

- name: Update apt
  apt: update_cache=yes cache_valid_time=86400
#http://docs.ansible.com/apt_module.html
  when: update_apt is defined and update_apt.changed == True

- name: Install postgres
  shell: apt-get install -q -y postgresql-9.1
  #apt: name=postgresql-9.1  state=present 

- others tasks...