# How to test if playbook is being run interactively

**URL:** <https://forum.ansible.com/t/how-to-test-if-playbook-is-being-run-interactively/36241>\
**Category:** Ansible Project\
**Created:** [January 21, 2022, 10:08pm UTC](https://forum.ansible.com/t/how-to-test-if-playbook-is-being-run-interactively/36241 "2022-01-21T22:08:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 21, 2022, 10:08pm UTC](https://forum.ansible.com/t/how-to-test-if-playbook-is-being-run-interactively/36241/1 "2022-01-21T22:08:54Z")

</div>

Hi

Somewhere halfway through one of our playbooks there is a ‘pause’ task that prompts for input:

- name: Database restoration - timestamp selection  
pause:  
prompt: |  
Select the number of a backup date to restore from:

{% for ts in backup\_timestamps\_available %}  
{{ (loop.index|string).ljust(8) ~ ‘%Y-%m-%d (%A) %H:%M:%S’ | strftime(ts) }}  
{% endfor %}  
echo: true  
register: ts\_select

when: db\_restore

But in some scenarios this playbook is being run from a shell wrapper, which can be non-interactive, in which case this step will bail with:

**[WARNING]: Not waiting for response to prompt as stdin is not interactive**

I’d like to gracefully stop right at the beginning when db\_restore is set but the play is not run interactively.

I can check in the shell wrapper, but that doens’t know about ansible extra vars.

Is there a way to check in the playbook for interactiveness?

thx

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 24, 2022, 3:07pm UTC](https://forum.ansible.com/t/how-to-test-if-playbook-is-being-run-interactively/36241/2 "2022-01-24T15:07:31Z")

</div>

No builtin way (yet) but you can setup a 'is\_interactive' vars\_prompt  
with default to 'no', when non interactive it will always be 'no'
