Muhammad Lukman Low
Muhammad Lukman Low

Reputation: 8533

How do you send the ENTER keypressed to ansible's expect?

I want to write playbook which installs an application using their installer. I am using ansible's expect module to do this. At the beginning of the installation, it asks to press ENTER to continue with the installation. How do I send expect the ENTER keypress ?

Upvotes: 3

Views: 7128

Answers (1)

Nick Roz
Nick Roz

Reputation: 4230

There’s a linux command called yes which "outputs an affirmative response, or a user-defined string of text".

I didn't check it, but you could try using:

- shell: yes '' | your command goes here

Have a look at simulation keypress in bash script.

Taken from documentation:

If you want to run a command through the shell (say you are using <, >, |, etc), you must specify a shell in the command such as /bin/bash -c "/path/to/something | grep else"

Therefore, you can try /bin/bash -c "echo" or something similar as a response, something like:

responses:
  press_enter: /bin/bash -c "echo"

Upvotes: 1

Related Questions