ansible / proposals

Repository for sharing and tracking progress on enhancement proposals for Ansible.
Creative Commons Zero v1.0 Universal
93 stars 19 forks source link

Define variable or fact when debug is set #106

Closed jdh239 closed 6 years ago

jdh239 commented 6 years ago

Proposal: Define variable or fact when debug is set

Author: jdh239

Date: 2018/04/18

Motivation

I would like to be able to skip or execute certain tasks based on debug verbosity level.

Problems

What problems exist that this proposal will solve?

Probably a lot of other scenarios to use this in, but that is all I have for right now.

Solution proposal

Set a variable or fact that can be used in conditionals based off of the verbosity level. (ie. ansible-playbook -vv myplay.yml)

meta: end_play when: verbosity >= 2

or

It would allow more flexibility while debugging. I can execute my playbook without debugging and have it execute the whole thing, or terminate early with debugging without having to constantly edit my playbook to add meta: end_play statements, etc.

sivel commented 6 years ago

This has recently been implemented in https://github.com/ansible/ansible/pull/38231 and will appear in the 2.6 release.

The var will be ansible_verbosity

jdh239 commented 6 years ago

Sweet! Thanks!