On 02.05.2019 13:56, Bubunia Patra wrote: > Hi all, > > I am writing a ansible playbook which will gather all the failed count from > script and after sum it will display in the report. > > For example: shell script fails that is called from the ansible fails with > exit 1, 2 for different cases with diff error message after the script runs > in different hosts. > > I want to gather the total number of failed count(exit 1 + exit 2) and > display it in stout. Can I use failed_when and changed_when to achieve this? > How do I get the sum? > > I want to handle this with in ansible to have a better control rather than in > shell script. How can I achieve this? > > If it's possible, Can anyone provide a small example to achieve this?
I don't understand what you are trying to do, but can give you answer on how to get the error code. If you use "register: myvar" on a shell task the variable "myvar.rc" contains the return code. Since Ansible stops a play on a host when rc > 0 you need to use "failed_when: false" or "ignore_errors: true". -- Kai Stian Olstad -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e77b3691-896e-6842-b30e-e1fc128dd67c%40olstad.com. For more options, visit https://groups.google.com/d/optout.
