好吧,这是我的任务:
---
- 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]
...复印后我应该会看到通知,有什么问题吗?
发布于 2014-12-04 17:07:48
---
- 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... 发布于 2014-12-04 14:52:11
http://wherenow.org/ansible-handlers/
事实上,这个问题是必要的,以迫使
---
- 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 updatehttps://stackoverflow.com/questions/25921632
复制相似问题