Hi,
Trying what I believe to be common use case where a playbook has set of
roles to configure system.
this looks something like
- name: Do X, Y and Z
hosts: all
roles:
- role: roleA
var1: value1
var2: value2
- role: roleB
var1: value1
var2: value2
- role: roleC
var1: value1
var2: value2
I found 2 issues with this set up.
1 - I have checks in each role to end_host in case there is no need to run
the playbook. I do understand that with correctly written (idempotent)
playbook this is not necessary but I found it to be very useful as one, it
does save a lot of execution time, especially when your play is big and
inventory even bigger but also when you are creating timestamped audit logs
that you want to be executed only if change happened. I also considered
breaking up tasks in more files so that they can be included on condition
but depending on the role it can get bit messy and hard to follow for other
contributors.
I've been using end_host but it ends play and not a role. *Is there a way
to end role and not play, and most of all not stop processing of other
roles in the lis*t?
2 - If role fails due to unhandled error, fail hat role but *again not a
play, and most of all do not stop processing of other roles in the lis*t?
I've looked into ignoring_errors but again that work on play level and not
role level. If role A fails ignore_errors will allow next play to be
executed but not roles B and C
So far the only solutions I can think of are:
- Have play for each role - not the end of the world, just a lot of
unnecessary code
- in AWX, have a playbook/job template for each role and string them
together using workflow - again a lot of unnecessary code and potentially
job templates.
- try and rap all in blocks and use rescue that just includes task with
nothing bur debug module
- have main task in the role to just do includes based on the conditions
and within blocks. Gets messy very quick
Is there a way to deal with 2 issues mentioned above? *What is the standard
approach to dealing with roles failing or exiting roles on condition when
executed in a stack/list?*
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/28fa1b72-4c6a-4b96-a1b7-58eeaef89ec3n%40googlegroups.com.