'How to include default and timeout for pause--prompt in ansible task

during a playbook run, I need to get user input.

It can only be run during the playbook run since I need to check if the file exists. if exists I will need to issue a prompt that asks the user to click 1 or 2. - I have managed to do this but I need to ass 2 more options to the prompt

  1. The prompt pause should wait for 10 seconds only
  2. If after 10 seconds the user didn't put any input the default will be "1"
  - name: generate_private_key
    pause:
      prompt: "Key exists, click [1] to skip the key creation or click [2] to re-create the 
               key - This will require you to distribute the keys"
      #default: 1  ### This is not working, saying it is not supported by a pause 
      echo: true
    register: crate_key
     when: is_private_exists.stat.exists == True


Solution 1:[1]

A task timeout is added in 2.10 release.

For example, below playbook fails in 2.10 version:

- name: generate_private_key
  prompt: "Key exists, click [1] to skip the key creation or click [2] to re-create the 
            key - This will require you to distribute the keys"
  default: 1
  register: crate_key
  when: is_private_exists.stat.exists == True
  timeout: 10

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 KrishnaR