You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.3 KiB

6 years ago
  1. ---
  2. - hosts: localhost
  3. become: false
  4. gather_facts: no
  5. vars:
  6. state: "present"
  7. ssh_key_id: "6536865"
  8. cloud_machine_type: 2gb
  9. regions:
  10. - nyc1
  11. - sfo1
  12. - nyc2
  13. - ams2
  14. - sgp1
  15. - lon1
  16. - nyc3
  17. - ams3
  18. - fra1
  19. - tor1
  20. - sfo2
  21. - blr1
  22. cloud_images:
  23. - coreos-beta
  24. - fedora-24-x64
  25. - centos-5-x64
  26. - centos-5-x32
  27. - fedora-25-x64
  28. - debian-7-x64
  29. - debian-7-x32
  30. - debian-8-x64
  31. - debian-8-x32
  32. - centos-6-x32
  33. - centos-6-x64
  34. - coreos-stable
  35. - ubuntu-16-10-x32
  36. - ubuntu-16-10-x64
  37. - freebsd-11-0-x64-zfs
  38. - freebsd-10-3-x64-zfs
  39. - coreos-alpha
  40. - ubuntu-12-04-x32
  41. - ubuntu-12-04-x64
  42. - ubuntu-16-04-x64
  43. - ubuntu-16-04-x32
  44. - ubuntu-14-04-x64
  45. - ubuntu-14-04-x32
  46. - centos-7-x64
  47. - freebsd-11-0-x64
  48. - freebsd-10-3-x64
  49. - centos-7-3-1611-x64
  50. mode: default
  51. tasks:
  52. - name: replace_test_id
  53. set_fact:
  54. test_name: "{{test_id |regex_replace('\\.', '-')}}"
  55. - name: show vars
  56. debug: msg="{{cloud_region}}, {{cloud_image}}"
  57. - set_fact:
  58. instance_names: >-
  59. {%- if mode in ['separate', 'ha'] -%}
  60. ["k8s-{{test_name}}-1", "k8s-{{test_name}}-2", "k8s-{{test_name}}-3"]
  61. {%- else -%}
  62. ["k8s-{{test_name}}-1", "k8s-{{test_name}}-2"]
  63. {%- endif -%}
  64. - name: Manage DO instances | {{state}}
  65. digital_ocean:
  66. unique_name: yes
  67. api_token: "{{ lookup('env','DO_API_TOKEN') }}"
  68. command: "droplet"
  69. image_id: "{{ cloud_image }}"
  70. name: "{{ item }}"
  71. private_networking: no
  72. region_id: "{{cloud_region}}"
  73. size_id: "{{cloud_machine_type}}"
  74. ssh_key_ids: "{{ssh_key_id}}"
  75. state: "{{state}}"
  76. wait: yes
  77. register: droplets
  78. with_items: "{{instance_names}}"
  79. - debug:
  80. msg: "{{droplets}}, {{inventory_path}}"
  81. when: state == 'present'
  82. - name: Template the inventory
  83. template:
  84. src: ../templates/inventory-do.j2
  85. dest: "{{ inventory_path }}"
  86. when: state == 'present'
  87. - name: Wait for SSH to come up
  88. wait_for: host={{item.droplet.ip_address}} port=22 delay=10 timeout=180 state=started
  89. with_items: "{{droplets.results}}"
  90. when: state == 'present'