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.

91 lines
2.2 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. - fedora-24-x64
  24. - centos-5-x64
  25. - centos-5-x32
  26. - fedora-25-x64
  27. - debian-7-x64
  28. - debian-7-x32
  29. - debian-8-x64
  30. - debian-8-x32
  31. - centos-6-x32
  32. - centos-6-x64
  33. - ubuntu-16-10-x32
  34. - ubuntu-16-10-x64
  35. - freebsd-11-0-x64-zfs
  36. - freebsd-10-3-x64-zfs
  37. - ubuntu-12-04-x32
  38. - ubuntu-12-04-x64
  39. - ubuntu-16-04-x64
  40. - ubuntu-16-04-x32
  41. - ubuntu-14-04-x64
  42. - ubuntu-14-04-x32
  43. - centos-7-x64
  44. - freebsd-11-0-x64
  45. - freebsd-10-3-x64
  46. - centos-7-3-1611-x64
  47. mode: default
  48. tasks:
  49. - name: replace_test_id
  50. set_fact:
  51. test_name: "{{ test_id |regex_replace('\\.', '-') }}"
  52. - name: show vars
  53. debug: msg="{{ cloud_region }}, {{ cloud_image }}"
  54. - name: set instance names
  55. set_fact:
  56. instance_names: >-
  57. {%- if mode in ['separate', 'ha'] -%}
  58. ["k8s-{{ test_name }}-1", "k8s-{{ test_name }}-2", "k8s-{{ test_name }}-3"]
  59. {%- else -%}
  60. ["k8s-{{ test_name }}-1", "k8s-{{ test_name }}-2"]
  61. {%- endif -%}
  62. - name: Manage DO instances | {{ state }}
  63. digital_ocean:
  64. unique_name: yes
  65. api_token: "{{ lookup('env','DO_API_TOKEN') }}"
  66. command: "droplet"
  67. image_id: "{{ cloud_image }}"
  68. name: "{{ item }}"
  69. private_networking: no
  70. region_id: "{{ cloud_region }}"
  71. size_id: "{{ cloud_machine_type }}"
  72. ssh_key_ids: "{{ ssh_key_id }}"
  73. state: "{{ state }}"
  74. wait: yes
  75. register: droplets
  76. with_items: "{{ instance_names }}"
  77. - debug: # noqa unnamed-task
  78. msg: "{{ droplets }}, {{ inventory_path }}"
  79. when: state == 'present'
  80. - name: Template the inventory
  81. template:
  82. src: ../templates/inventory-do.j2 # noqa 404 CI templates are not in role_path
  83. dest: "{{ inventory_path }}"
  84. mode: 0644
  85. when: state == 'present'