Placement of vars_promt

My test playbook for the flow I want is shown below:

I want some work done, then prompt the user, then more work, a pause, and the end.

The thing is that the prompt comes up even before gathering facts, not as suggested by its placement in the playbook.

Can the prompting be done between tasks?

Thanks

Ansible plays are hashes, they are a collection of attributes.

Tasks are an ordered list.

Thus including “vars_prompt” ahead or behind “tasks” makes no difference.

vars_prompt happens before the current play runs, every time.

You can solve this problem by stopping the current play, starting a new one with a vars_prompt in it, and then continuing, since a playbook can contain multiple plays in a single file.

Many thanks. I apologize but I am not proficient enough to know what you mean exactly.

Something like this?

Basically.

You can consolidate and get the same effect:

Hi Petros,

Seems you are asking a bit of a different question…

I don’t particularly like this suggested approach because it conflates two very different concepts - prompting with setting variables, in one line that is hard to read. Also, ansible only accepts one value for each argument, so specifying prompt twice is weird, and specifying the name of the variable in the prompt string is very un-ansible-like as well.

Two, it sounds like what you really would want is a new action plugin called “prompt”, which I would be open to, which would look a lot like the source to pause.py

  • prompt: var=“foo” message=“foo?”
  • prompt: var=“spork” message=“Sporks are cool?”
  • set_fact: combined=“{{ foo }}-{{ spork }}”

Hi Petros,

I’m Joseph, actually.

Gratitude for all your replies.

You are welcome, though that particular reply about new set_fact syntax was for Petros :slight_smile:

The other was for you though :slight_smile: