| 123456789101112131415161718192021222324252627282930 |
- - 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: PUTing name,ip on database
- uri: >
- url="http://localhost:8080/machines/{{dogroupname}}/{{item['droplet']['name']}}/{{ item['droplet']['ip_address'] }}"
- method=PUT
- 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 }}"
|