andrewvaughan / ansible-role-prompt

Ansible plugin for messaging and prompting the user during a playbook.
MIT License
10 stars 2 forks source link

NameError: name 'raw_input' is not defined #83

Open scuben opened 5 years ago

scuben commented 5 years ago

Project Details

Error on every prompt attempt

The full traceback is:
Traceback (most recent call last):
  File "/usr/local/Cellar/ansible/2.7.10/libexec/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 140, in run
    res = self._execute()
  File "/usr/local/Cellar/ansible/2.7.10/libexec/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 612, in _execute
    result = self._handler.run(task_vars=variables)
  File "/Users/patricklandolt/.ansible/roles/andrewvaughan.prompt/action_plugins/prompt.py", line 96, in run
    return self._prompt(result, args['msg'])
  File "/Users/patricklandolt/.ansible/roles/andrewvaughan.prompt/action_plugins/prompt.py", line 210, in _prompt
    var = raw_input(askstr)
NameError: name 'raw_input' is not defined

fatal: [staging.radiant.artack.ch]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

I think this is the problem of using python3 as they removed raw_input (ref: https://www.python.org/dev/peps/pep-3111/)

mx781 commented 3 years ago

Doing manual installation as per the plugin's README and then changing raw_input to input fixes this for Python 3. @andrewvaughan if you're still maintaining this happy to file a PR that makes it cross-compatible.

cosaintneal commented 3 years ago

Installing via ansible-galaxy, then changing raw_input to input fixes this for Python 3. I agree with @mx781 that this fix would benefit the community, can we make a PR @andrewvaughan?

andrewvaughan commented 3 years ago

Hey all - I'm a little tight on time right now (having my first kid!) but I'm still supporting this project. If anyone wishes to submit a PR I'll definitely make sure it gets in.