Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'DoError' is not defined #50

Open
rot26 opened this issue Aug 17, 2016 · 12 comments
Open

'DoError' is not defined #50

rot26 opened this issue Aug 17, 2016 · 12 comments

Comments

@rot26
Copy link

rot26 commented Aug 17, 2016

Greetings @zbal ,

I am hitting an issue with dopy where it throws a NameError: name 'DoError' is not defined.

Here is what I am doing...

Playbook: 'digitalocean.yml'


---
- hosts: digitalocean

  vars:
    do_token: '<###api-token-removed###>'
    droplets:
      - droplet-one
      - droplet-two

  tasks:
...
  - name: ensure key exists at DigitalOcean
    digital_ocean:
      state=present
      command=ssh
      name=my_ssh_key
      ssh_pub_key={{ lookup('file', '~/.ssh/id_rsa.pub') }}
      api_token={{ do_token }}
    register: my_ssh_key
...

Running ansible playbook in verbose mode:

$ ansible-playbook digitalocean.yml -vvv
...
<localhost> PUT /var/folders/v1/by8l5ggn4ns9807gmry4vcjc0000gn/T/tmpJdHJ9o TO /Users/chris/.ansible/tmp/ansible-tmp-1471407681.76-24571883284830/digital_ocean
<localhost> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /Users/username/.ansible/tmp/ansible-tmp-1471407681.76-24571883284830/digital_ocean; rm -rf "/Users/username/.ansible/tmp/ansible-tmp-1471407681.76-24571883284830/" > /dev/null 2>&1 && sleep 0'

The next line shows this Error:

An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/var/folders/v1/by8l5ggn4ns9807gmry4vcjc0000gn/T/ansible_z8mUWU/ansible_module_digital_ocean.py", line 187, in <module>
    class TimeoutError(DoError):
NameError: name 'DoError' is not defined

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_name": "digital_ocean"}, "module_stderr": "Traceback (most recent call last):\n  File \"/var/folders/v1/by8l5ggn4ns9807gmry4vcjc0000gn/T/ansible_z8mUWU/ansible_module_digital_ocean.py\", line 187, in <module>\n    class TimeoutError(DoError):\nNameError: name 'DoError' is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}

I am not sure how to debug this further. Any suggestions?
Cheers!

@kontrafiktion
Copy link

which version of dopy did you install on the target machine(s)?

@rot26
Copy link
Author

rot26 commented Aug 22, 2016

Hi @kontrafiktion,

I am running dopy-0.3.7 on my mac (el capitan) 10.11.6. I tried both python2.7 and python3.5 using pip 8.1.2

As I understand it, ansible is using dopy for the digital ocean api wrapper to create the machines, so I do not have dopy installed on those target machines, only my main command and control machine.

@kontrafiktion
Copy link

Your playbook above says hosts: digitalocean ... Do you have dopy installed on that machine? And you might want to try dopy-0.3.7a

@kontrafiktion
Copy link

kontrafiktion commented Aug 22, 2016

Ah, I totally forgot: you might need to add the following to the 'digitalocean' declaration in inventory:

ansible_python_interpreter=python

See ansible/ansible-modules-core#2509 (comment)

@oddjobz
Copy link

oddjobz commented Aug 31, 2016

Ok, this has been working fine for me for most of the year .. now something has upgraded and I'm getting;

NameError: name 'DoError' is not defined

I've tried messing with different versions of dopy from 0.3.5 to 0.3.7.a, doesn't seem to make any difference, and I've tried adding the other suggested options, but nothing seems to make a difference.
This seems like a pretty fundamental issue - does anyone have a fix?

@oddjobz
Copy link

oddjobz commented Aug 31, 2016

Looking at "digital_ocean.py", it's failing to find "dopy", even though I've checked the executable running is /usr/bin/python, and /usr/bin/python can import "dopy" fine from the command prompt. Is Ansible / digital_ocean messing with the import path?

@kontrafiktion
Copy link

see #50 (comment)

@oddjobz
Copy link

oddjobz commented Sep 1, 2016

Mmm, not helpful. If you mean add th ansible_python_interpreter, yes, done that - no difference. If you mean try 0.3.7a, yes, done that too. I've inserted code to check the executable is what it should be, and I've tried removing some "try" blocks to clarify the error. For some reason it thinks "dopy" is not a module when it clearly is.

@kontrafiktion
Copy link

I only have seen this error, when the target machine on which Ansible is executing the playbook does not have dopy installed for the "python" that is used by Ansible.

  1. What is the "host" used in your playbook? localhost? Ideally post a minimal playbook.
  2. If you open a python shell on that host (with the python indicated by ansible_python_interpreter: does "import dopy" work?

@oddjobz
Copy link

oddjobz commented Sep 1, 2016

I'm a little past that .. I'm messing around with "digital_ocean.py", from what I can see there's some sort of virtual environment or chrooting going on, which is bizarre. If I get digital_ocean.py to print out some stuff just before it bails, it confirms both the executable and the PYTHONPATH stuff is correct, but if I use "walk" to list the contents of the folder that should contain "dopy", it's just not there .. whereas outside of the program it IS there .. so as far as I can see it's not a function of the Python binary in use - it's an issue with the binary being able to "see" the folders it's modules are in. Will investigate further.

@oddjobz
Copy link

oddjobz commented Sep 1, 2016

Ok, ignore me - something has removed "dopy" from my live server, I think I'm looking for the problem in the wrong place ...

@oddjobz
Copy link

oddjobz commented Sep 1, 2016

Ok, fixed by adding (-e 'ansible_python_interpreter=pypy') to the Ansible command line .. I think I can see what the issue "is", the development box is running Ansible using cpython, while the deployment server is using pypy .. but this has always been the case (or so I thought) and it's been working daily ... I need to work out what changed ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants