Guest User

Untitled

a guest
Jan 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. [DIGITALOCEAN]
  2. localhost ansible_connection=local
  3.  
  4. [PROVISION]
  5. TEST1
  6. TEST2
  7. TEST3
  8.  
  9. [DROPLETS]
  10. TEST1 ansible_ssh_host=x.x.x.x
  11. TEST2 ansible_ssh_host=y.y.y.y
  12. See, this one never seems to make it in... It changes too, and they get unordered too.
  13.  
  14. ---
  15. - hosts: PROVISION
  16. gather_facts: no
  17.  
  18. vars:
  19. do_token: TOKEN
  20.  
  21. tasks:
  22. - name: Create new droplet
  23. digital_ocean: >
  24. state=present
  25. command=droplet
  26. name={{ inventory_hostname }}
  27. unique_name=yes
  28. size_id=512mb
  29. region_id=nyc3
  30. image_id=ubuntu-18-04-x64
  31. ssh_key_ids=KEY
  32. api_token={{ do_token }}
  33. wait=yes
  34. wait_timeout=500
  35. register: hostname
  36. delegate_to: localhost
  37.  
  38. - name: Add host to Ansible config
  39. lineinfile:
  40. dest: "/etc/ansible/hosts"
  41. insertafter: '^[DROPLETS]'
  42. state: present
  43. line: "{{ hostname.droplet.name }} ansible_ssh_host={{ hostname.droplet.ip_address }}"
  44. delegate_to: localhost
Add Comment
Please, Sign In to add comment