main.yml 1.0 KB

123456789101112131415161718192021222324252627282930
  1. - name: ensure droplets exist
  2. digital_ocean: >
  3. state=present
  4. command=droplet
  5. unique_name=yes
  6. name={{ item }}
  7. size_id=512mb
  8. region_id=nyc1
  9. image_id=debian-8-x64
  10. ssh_key_ids={{ desktap.ssh_key.id }}
  11. with_items: "{{ droplets }}"
  12. register: droplet_details
  13. - name: PUTing name,ip on database
  14. uri: >
  15. url="http://localhost:8080/machines/{{dogroupname}}/{{item['droplet']['name']}}/{{ item['droplet']['ip_address'] }}"
  16. method=PUT
  17. with_items: "{{ droplet_details.results }}"
  18. - name: Add new droplet to host group
  19. local_action: add_host hostname={{ item['droplet']['ip_address'] }} groupname={{ dogroupname }}
  20. with_items: "{{ droplet_details.results }}"
  21. - name: Wait for SSH to come up
  22. local_action: wait_for host={{ item['droplet']['ip_address'] }} port=22 delay=5 timeout=320 state=started
  23. with_items: "{{ droplet_details.results }}"
  24. - name: Keyscan droplets
  25. local_action: shell ssh-keyscan {{ item['droplet']['ip_address'] }} >> ~/.ssh/known_hosts
  26. with_items: "{{ droplet_details.results }}"