How can I use Ansible expect module to say yes for this prompt.
Are you sure you want to continue (yes/no)?
I tried to use this in vain. I think Ansible does not like characters like
these - *( , / , ) , ?*
Ansible and expect like them. But responses in expect is regexp and (, ) and ? and many more is special character,
for a full list see https://docs.python.org/2/library/re.html
- expect:
command: /my/command
responses:
Are you sure you want to continue (yes/no)?: yes
The special characters need to be escaped since you mean them literally.
Try this
Are you sure you want to continue \(yes/no\)\?: yes
I did tried that earlier but encountered below error
`
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “/var/folders/qw/5nbqbmj97hsfz3z5lkwqk9lr0000gn/T/ansible_eLtUlG/ansible_module_expect.py”, line 230, in
main()
File “/var/folders/qw/5nbqbmj97hsfz3z5lkwqk9lr0000gn/T/ansible_eLtUlG/ansible_module_expect.py”, line 149, in main
response = u’%s\n’ % value.rstrip(‘\n’).decode()
AttributeError: ‘bool’ object has no attribute ‘rstrip’
fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_name”: “expect”}, “module_stderr”: “Traceback (most recent call last):\n File "/var/folders/qw/5nbqbmj97hsfz3z5lkwqk9lr0000gn/T/ansible_eLtUlG/ansible_module_expect.py", line 230, in \n main()\n File "/var/folders/qw/5nbqbmj97hsfz3z5lkwqk9lr0000gn/T/ansible_eLtUlG/ansible_module_expect.py", line 149, in main\n response = u’%s\n’ % value.rstrip(‘\n’).decode()\nAttributeError: ‘bool’ object has no attribute ‘rstrip’\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”, “parsed”: false}
I am stuck @ similar place where I have to say enter after y when ‘Do you accept this license[y/n]’ . I have given following CODE and stuck, Any help appreciated.
-Murthy
responses: ‘Press [Enter] to continue:’: \n ‘Do you accept this license?[y/n]’: y\n