Wrapping roles inside blocks to catch failures

52 views
Skip to first unread message

David Moreau Simard

unread,
Dec 7, 2015, 11:15:02 AM12/7/15
to Ansible Project
I love the idea around the new block feature in Ansible 2.

The example in the documentation includes tasks, I wanted to know if there was other areas/scopes in which we could include them ?

It doesn't look like I can get my two use cases to work. Something like this (pseudo-code):

1)
# playbook.yml
- name: Include roles
  hosts
: localhost
  roles
:
   
- block:
     
- role: create
     
# Anything in the test role can fail
     
- role: test
    always
:
     
- role: destroy

2)
# playbook.yml
block:
 
- name: Create stuff
    hosts
: localhost
    roles
:
     
- role: create

  - name: Test stuff
    hosts: test-servers
    roles:
      - role: test

always:
  - name: Destroy stuff
    hosts: localhost
    roles:
      - role: destroy


Any input is appreciated !

tiny...@gmail.com

unread,
Nov 20, 2016, 7:57:54 AM11/20/16
to Ansible Project
Would like to do the same trick.
Have you found any workaround?
Reply all
Reply to author
Forward
0 new messages