# Ansible Expect module can't match string/regex script questions

**URL:** <https://forum.ansible.com/t/ansible-expect-module-cant-match-string-regex-script-questions/22393>\
**Category:** Ansible Project\
**Created:** [August 26, 2016, 9:16am UTC](https://forum.ansible.com/t/ansible-expect-module-cant-match-string-regex-script-questions/22393 "2016-08-26T09:16:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Francesco\_Spe](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Andrea\_Francesco\_Spe](https://forum.ansible.com/u/Andrea_Francesco_Spe)\
**Post date:** [August 26, 2016, 9:16am UTC](https://forum.ansible.com/t/ansible-expect-module-cant-match-string-regex-script-questions/22393/1 "2016-08-26T09:16:34Z")

</div>

I’m trying to automate a script installation through Ansible in a Vagrant machine.

I tried a lot to find a solution across the web but the documentation and the examples are very weak.

That script I’m trying to install is prompting questions that I’m trying to answer programmatically with the **Ansible Expect Module**.

Ansible Task:

- name: “Running Lisk installation”  
become: True  
become\_user: vagrant  
expect:  
command: bash installLisk.sh install -r {{env}}  
responses:  
‘Where do you want to install Lisk to? (Default /home/vagrant)’: “/home/vagrant”  
‘Would like to install NTP? (y/n):’: “y”  
echo: yes

It seems it can’t recognize the question or the answer, **this is the error I’m getting back** from the provisioning

TASK [lisk : Running Lisk installation] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

fatal: [default]: FAILED! =\> {  
“changed”: true,  
“cmd”: “bash installLisk.sh install -r test”,  
“delta”: “0:00:30.137468”,  
“end”: “2016-08-26 08:18:46.740017”,  
“failed”: true,  
“rc”: null,  
“start”: “2016-08-26 08:18:16.602549”,

“stdout”: "Checking prerequisites:\r\n  
Curl is installed.\t\t\t\t\t\u001b[32mPassed\u001b(B\u001b[m\r\n  
Tar is installed.\t\t\t\t\t\u001b[32mPassed\u001b(B\u001b[m\r\n  
Wget is installed.\t\t\t\t\t\u001b[32mPassed\u001b(B\u001b[m\r\n  
Sudo is installed and authenticated.\t\t\t\u001b[32mPassed\u001b(B\u001b[m\r\n  
u001b[32mAll preqrequisites passed!\u001b(B\u001b[m\r\n  
Where do you want to install Lisk to? (Default /home/vagrant): ",

“stdout\_lines”: [  
“Checking prerequisites:”,  
“Curl is installed.\t\t\t\t\t\u001b[32mPassed\u001b(B\u001b[m”,  
“Tar is installed.\t\t\t\t\t\u001b[32mPassed\u001b(B\u001b[m”,  
“Wget is installed.\t\t\t\t\t\u001b[32mPassed\u001b(B\u001b[m”,  
“Sudo is installed and authenticated.\t\t\t\u001b[32mPassed\u001b(B\u001b[m”,  
“\u001b[32mAll preqrequisites passed!\u001b(B\u001b[m”,  
"Where do you want to install Lisk to? (Default /home/vagrant): "  
]}

**Thank you** all guys in advance

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 29, 2016, 3:05pm UTC](https://forum.ansible.com/t/ansible-expect-module-cant-match-string-regex-script-questions/22393/2 "2016-08-29T15:05:16Z")

</div>

Since responses is regex, you need to escape all the regex special character with a backspace that you mean literally.
