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 ?
Asked
Active
Viewed 6,231 times
3

Muhammad Lukman Low
- 8,177
- 11
- 44
- 54
-
have you tried `child.sendline()`? – jfs Jul 01 '16 at 14:52
1 Answers
1
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"
-
I want to use this with the `expect` module not the `shell` module. – Muhammad Lukman Low Jul 07 '16 at 10:32
-
Have a look at [documentation](http://docs.ansible.com/ansible/expect_module.html), you can try `echo` as answer – Nick Roz Jul 07 '16 at 10:43
-
@LowKianSeong, I've altered answer a little. If you solved your problem and you have something to add - improve it! I might've mistaken with syntax – Nick Roz Jul 11 '16 at 08:20