pre_tasks: 先于tasks部分执行的部分

post_tasks: 不管tasks部分成功或者失败,都会被执行

---
– hosts: all
   become: true
   pre_tasks:
     – name: start tasks and sent notifiaction to HipChat
       hipchat:
         color: purple
         token: “{{ hipchat_token }}”
         room: “{{ hipchat_room }}”
         msg: “[Start] Run ‘foo/setup.yml’ playbook on {{ ansible_nodename }}.”

  roles:
     – chusiang.vim-and-vi-mode

  vars:
     …

  tasks:
     – name: include main task
       include: tasks/main.yml

  post_tasks:
     – name: finish tasks and sent notifiaction to HipChat
       hipchat:
         color: green
         token: “{{ hipchat_token }}”
         room: “{{ hipchat_room }}”
         msg: “[Finish] Run ‘foo/setup.yml’ playbook on {{ ansible_nodename }}.”

# vim:ft=ansible :