Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small suggestion for Chapter 11 fail/assert remarks #191

Closed
pestophagous opened this issue Dec 13, 2019 · 2 comments
Closed

Small suggestion for Chapter 11 fail/assert remarks #191

pestophagous opened this issue Dec 13, 2019 · 2 comments

Comments

@pestophagous
Copy link

pestophagous commented Dec 13, 2019

Thank you for your highly useful and highly readable book on Ansible. I have dog-eared my copy extensively!

In Chapter 11 there is a section named "The fail and assert modules".

It currently says:

Both fail and assert, when triggered, will abort the playbook
run, and the only difference is in the simplicity of their usage.

I humbly suggest amending that to something like:

Both fail and assert, when triggered, will abort the playbook
run. The choice between these two is one of style and simplicity.

One subtle difference is that a 'fail' task will be reported as
'skipped' in the final recap statistics when the failure is not
triggered.

If your playbook contains a single 'fail' task that is happily
not triggered, the playbook results will contain:

PLAY RECAP *********************************************************************
default                    : .......(snip)....    skipped=1

If your playbook instead contains a single 'assert' task that is
happily not triggered, you will see "skipped=0" and the
individual task outcome will be:

TASK [my_assert] ****************************************
ok: [default] => {
    "changed": false,
    "msg": "All assertions passed"
}

This subtlety about "skipped" task count can be relevant in scenarios where one must audit and justify tasks that have been skipped.

@geerlingguy geerlingguy changed the title Small suggestion for Chapter 11 fail/assert remarks (in response to "help improve this book") Small suggestion for Chapter 11 fail/assert remarks Dec 31, 2019
@geerlingguy
Copy link
Owner

geerlingguy commented Dec 31, 2019

That's a good point! Didn't even think about that use case, but that would be one case where it's probably best to use assert rather than fail.

@geerlingguy
Copy link
Owner

geerlingguy commented Jul 25, 2020

I have updated the book with something along the lines of your suggestion. Thanks for the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants