Ansible: Perform Cleanup on Task Failure

前端 未结 3 494
梦毁少年i
梦毁少年i 2021-02-07 00:14

I\'m currently writing an Ansible play that follows this general format and is run via a cron job:

pre_tasks:
  -Configuration / package installation

tasks:
           


        
相关标签:
3条回答
  • 2021-02-07 00:29

    Don't use post_tasks block but rather have your cleanup process as part of regular tasks.

    0 讨论(0)
  • 2021-02-07 00:42

    You should use handlers (http://docs.ansible.com/ansible/playbooks_intro.html) and set:

    force_handlers: true

    Please give a look to KubeNow's integration test (https://github.com/kubenow/KubeNow/blob/master/test/integration-test.yml).

    0 讨论(0)
  • 2021-02-07 00:46

    This feature became available in Ansible 2.0:

    This is the documentation for the new stanza markers block, rescue, and always.

    0 讨论(0)
提交回复
热议问题