I’ve been using Ansible to provision DigitalOcean instances using the digital_ocean module, which was going well until it became apparent that I didn’t need the slugs for provisioning (e.g. size: 512mb or region: lon1), but a numeric index. After digging around (admittedly not very far) I could only find the codes exposed via the v1 API. Since you can import vars files in Ansible, I’ve written a small script to turn the API responses for images, regions, and sizes into usable variable names for easy importing.
It generates a yaml file which looks like this:
The source is available here with a version that I pulled today. Just drop this file into your vars, import with
and use as below
It’s not a perfect solution, but this should do until Ansible starts supporting slugs instead of codes in their digital_ocean module.