Question
Has anyone gotten Ansible 2.0 to work w/ the DigitalOcean v2 API?
There seems to be a lack of well-documented examples of using the new Ansible 2.0 digital_ocean module to create DO droplets, using the v2 API. If anyone has done it, could you share a working code example please? Thanks!
Also posted more about this here: https://digitalocean.uservoice.com/forums/136585-digitalocean/suggestions/8883373-create-docs-for-ansible-2-0-do-v2-api
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
Hello
I started a similar challenge last weekend, and so far only managed to realize the same as you: documentation shows Ansible v2 but only v1.9 is available, so there is a lack of coherence with the doc.
This is how I was trying to launch a droplet before quitting to do other stuff. See my playbook in case it can help:
demo_setup.yml
tasks:
# Create a new Droplet
# Will return the droplet details including the droplet id (used for idempotence)
Just for clarity: there are 2 problems
Good luck :) I’ll try again this weekend
Hi marcosgm: I’m using Ansible from git checkout, since they’re supposed to announce/release Ansible 2 this month or Real-Soon-Now. Also, DO is obsoleting the v1 API completely by this Fall, so one should avoid it.
That being said, things still don’t work from Ansible to create DO droplets. I’ll try again a bit later. But someone from DO should look into this, it’s in their direct financial interest to make it easier for people to spin-up more droplets. :-)
This thread is kind of old, but I have Ansible 2.0 (built from source see here:http://docs.ansible.com/ansible/intro_installation.html) running against v2 api.
Don’t forget to: sudo pip install dopy (found this out by tracing errors :(
can create droplets no problem. the ansible example fails due to misnamed slug.
Hi there,
I’m new to Ansible, but am making some progress and managed to get this working with version 2.0.2 on a ubuntu machine (at least to the place where I can create machines).. other testing still in progress........
This should help you out…… (please experiment on an image or do a droplet snapshot first just in case!). I know VERY little about Python at this time and it could mess up your machine. Use at your own risk.
The module was not properly finding something called DoError.
I did some research and the following as pre-requisites to recompiling using pip –upgrade. The first issue appears to be that IF you need to upgrade modules the apt package for ansible (I use ubuntu) was missing some dependencies to recompile (or upgrade). I did not previously have python installed so everything necessary isn’t there to –upgrade using pip.
To allow me to compile Phython modules, I did this…
Now, you can compile (upgrade the modules that were missing from the ansible package.
You might need to run this with (I haven’t figured out the python pip way of thinking yet.. Do what makes sense for you.
Now, you should be able to run the digitalocean: role in v2 (at least I can).
Here’s a code snippet for you that I have actually USED to create a DO droplet..
My ansible version is… 2.0.0.2
Here’s a code snippet that seems to actually work… (the whole “>” thing is totally new to me.. Nothing in the ansible world seems to work that way.. I converted it to what the documentation generally says for parameters).
This worked (key adjusted of course)…
If you want a gist, you can grab it here.
Example
Good luck.