How to have unique_name with Ansible and DO?

Trying to get my Ansible playbook to keep unique_names, but I can't get this feature to work. Followed the tutorial on Ansible with DO 2.0 Api, but every time I run my playbook, totally new droplets are created with the SAME names!

Leave a Comment

One thing I noticed that would cause this is that your uniquename: yes statement should instead be uniquename=yes to match the tutorial:

name: ensure droplet one exists
digitalocean: >
state=present
command=droplet
name=droplet-one
uniquename=yes
size_id=512mb
Additionally, it's likely the dual name declarations will cause an issue - It looks like you will need to use either - name: ensure key exists at DigitalOcean or - name: ensure droplets exist for this to work as expected.

Either format seems to work (and frankly is easier to read using key:value), and in fact it otherwise works fine with no errors, with all of the set values, for size, region, image_id etc. Just to be sure, I converted the format back to the tutorial and it was no different: every time I ran it, another droplet is created with the same name.

I had the same issue. Downgrading ansible to version 2.0 worked for me:

sudo pip install 'ansible>=2.0,<2.1'

If you then run your playbook you will see the following deprecation warning which points to the actual issue with latest ansible versions:

[DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the
full variable syntax ('{{droplet_details.results}}').
This feature will be removed in a future release. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.