Quantcast
Viewing latest article 10
Browse Latest Browse All 157

adding ansible_python_interpreter to task with expect module fails to get command with become_user

I'm writing a task for CentOS7 inventory in which have to go through prompt dialogues, which I think is best candidate for andible's expect module.

- name: setup some command  become: yes  become_user: user1  expect:    command: some_command    responses:'Do you want to continue? [yes/no]': 'y'

Above task required pexpect package on inventory, and version available is 2.3as shown in below error, whereeas expected version: >=3.3

fatal: [target1]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "Insufficient version of pexpect installed (2.3), this module requires pexpect>=3.3. Error was 'module' object has no attribute '_run'"}

As a workaround I installed python3 and it's pexpect module on inventory, and specified ansible_python_interpreter in the task to resolve it.this time it was unable to locate the command for the become_user

- name: setup some command  vars:    ansible_python_interpreter: /usr/bin/python3  become: yes  become_user: user1  expect:    command: some_command    responses:'Do you want to continue? [yes/no]': 'y'

Below is the error for the task

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: some_command.fatal: [target1]: FAILED! => {"changed": false, "msg": "The command was not found or was not executable: some_command."}

please suggest what's missing


Viewing latest article 10
Browse Latest Browse All 157

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>