I recommend you create roles for post and pre tasks for you ansible.
Your site.yml must be some like this:
---
- hosts: localhost
remote_user: "{{remote_user}}"
sudo: yes
gather_facts: false
roles:
- pre
- main_role
- post
in roles folder you must have three roles, pre, post and main_role.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…