Question
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!
Here’s my playbook, which otherwise works fine.
---
- hosts: digitalocean
vars:
do_token: xxxx
droplets:
- droplet-one
- droplet-two
tasks:
- name: ensure key exists at DigitalOcean
digital_ocean: >
state=present
command=ssh
name=demo
ssh_pub_key={{ lookup('file', '~/.ssh/id_rsa.pub') }}
api_token={{ do_token }}
register: demo
- name: ensure droplets exist
digital_ocean:
state: present
command: droplet
name: "{{item}}"
unique_name: yes
size_id: 512mb
region_id: sfo1
image_id: 15764687
private_networking: "yes"
ssh_key_ids: "{{ demo.ssh_key.id }}"
api_token: "{{ do_token }}"
with_items: "{{droplets}}"
register: droplet_details
- debug: msg="IP is {{ item.droplet.ip_address }}"
with_items: droplet_details.results
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.
×
Using dopy 0.3.5, the private networking option also does not work, however will work if you use dopy 0.3.6.
dopy 0.3.7 is broken and will cause a