| 12345678910111213141516171819202122232425262728 |
- - name: ensure droplets exist
- digital_ocean: >
- state=present
- command=droplet
- unique_name=yes
- name={{ item }}
- size_id=512mb
- region_id=nyc1
- image_id=debian-8-x64
- ssh_key_ids={{ desktap.ssh_key.id }}
- with_items: "{{ droplets }}"
- register: droplet_details
- - name: Save IP/ID/Group to file
- local_action: copy content="{{ item['droplet']['ip_address'] }}" dest="/tmp/outfile{{item['droplet']['name']}}"
- with_items: "{{ droplet_details.results }}"
- - name: Add new droplet to host group
- local_action: add_host hostname={{ item['droplet']['ip_address'] }} groupname={{ dogroupname }}
- with_items: "{{ droplet_details.results }}"
- - name: Wait for SSH to come up
- local_action: wait_for host={{ item['droplet']['ip_address'] }} port=22 delay=5 timeout=320 state=started
- with_items: "{{ droplet_details.results }}"
- - name: Keyscan droplets
- local_action: shell ssh-keyscan {{ item['droplet']['ip_address'] }} >> ~/.ssh/known_hosts
- with_items: "{{ droplet_details.results }}"
|