code snippet
- name: Execute test expect
ansible.builtin.expect:
command: /home/paul/test.sh
responses:
enter name: “Peter”
become: true
become_user: Paul
Fails with below error
{
“exception”: "Traceback (most recent call last):
File "", line 102, in
File "", line 94, in _ansiballz_main
File "", line 40, in invoke_module
File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)\n File "/tmp/ansible_ansible.builtin.expect_payload_ts_2 tdo/ansible_ansible.builtin.expect_payload.zip/ansible/modules/commands/expect.py", line 246, in
File "/tmp/ansible_ansible.builtin.expect_payload_ts_2_tdo/ansible_ansible.builtin.expect_payload.zip/ansible/modules/commands/expect.py", line 205, in main
File "/home/paul/.local/lib/python3.6/site-packages/pexpect/run.py", line 100, in run
cwd=cwd, env=env, **kwargs)
File "/home/paul/.local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 205, in init
self._spawn(command, args, preexec_fn, dimensions)
File "/home/paul/.local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 304, in _spawn
cwd=self.cwd, **kwargs)
File "/home/paul/.local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 315, in _spawnpty
return ptyprocess.PtyProcess.spawn(args, **kwargs)
File "/home/paul/.local/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 336, in spawn
raise exception
OSError: [Errno 8] Exec format error
",