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.

93 lines
2.3 KiB

6 years ago
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. - name: set instance names
  58. set_fact:
  59. instance_names: >-
  60. {%- if mode in ['separate', 'ha'] -%}
  61. ["k8s-{{ test_name }}-1", "k8s-{{ test_name }}-2", "k8s-{{ test_name }}-3"]
  62. {%- else -%}
  63. ["k8s-{{ test_name }}-1", "k8s-{{ test_name }}-2"]
  64. {%- endif -%}
  65. - name: Manage DO instances | {{ state }}
  66. digital_ocean:
  67. unique_name: yes
  68. api_token: "{{ lookup('env','DO_API_TOKEN') }}"
  69. command: "droplet"
  70. image_id: "{{ cloud_image }}"
  71. name: "{{ item }}"
  72. private_networking: no
  73. region_id: "{{ cloud_region }}"
  74. size_id: "{{ cloud_machine_type }}"
  75. ssh_key_ids: "{{ ssh_key_id }}"
  76. state: "{{ state }}"
  77. wait: yes
  78. register: droplets
  79. with_items: "{{ instance_names }}"
  80. - debug:
  81. msg: "{{ droplets }}, {{ inventory_path }}"
  82. when: state == 'present'
  83. - name: Template the inventory
  84. template:
  85. src: ../templates/inventory-do.j2 # noqa 404 CI templates are not in role_path
  86. dest: "{{ inventory_path }}"
  87. when: state == 'present'