On Wednesday, 26 September 2018 10.33.34 CEST Guillaume Jeanne wrote:
> Hey,
> 
> I have a script that i want to use with ansible. This script asks questions
> so I'm trying to use the expect module as below :
> 
> - name: Answer in term to the openvpn script to configure it
> expect:
> command: ./{{ script_name }}
> responses:
> IP address: '51.75.15.139'
> Do you want to enable IPv6 support \(NAT\)\? \[y\/n\]: 'n'
> Port choice \[1\-3\]: '1'
> Protocol \[1\-2\]: '1'
> DNS \[1\-10\]: '6'
> Enable compression\? \[y\/n\]: 'n'
> Customize encryption settings\? \[y\/n\]: 'n'

- aka dash don't need to be escaped, the same goes for / aka slash.


> Press any key to continue\.\.\.: 'a'

On "Press any key" just use ''


> become: yes
> 
> Problem is : At start it took me some times to understand escape char.

You only need to escape regexp special characters.


> So any time I failed, ansible would timeout and tell me which questions
> in the script had fail. Since then I succeed the second question and
> Ansible told me prob was q.3 (as expected).
> But since i had the other question (even if I had them one by one)
> Ansible won't timeout but it's not working properly as it stays in this
> task for ever.
> Anyone would know why it doesn't timeout and also why it isn't working ?

Never had the problem that expect doesn't timeout, you could try to run Ansible 
with -vvv, but I doubt you get any more information, but worth a shot.

If you remove the unnecessary escapes as mention above and -vvv don't give you 
any tips you need to debug 
https://docs.ansible.com/ansible/2.5/dev_guide/developing_modules_general.html?highlight=ansible_keep_remote_files#debugging-remote


-- 
Kai Stian Olstad


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3152692.o9XMLuS3Ux%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to