c12s-kubespray/tests/cloud_playbooks/create-do.yml

49 lines
1.3 KiB
YAML
Raw Normal View History

2017-02-20 15:51:48 +00:00
---
- hosts: localhost
become: false
gather_facts: no
vars:
cloud_machine_type: g1-small
mode: default
tasks:
- name: replace_test_id
set_fact:
test_name: "{{test_id |regex_replace('\\.', '-')}}"
- set_fact:
instance_names: >-
{%- if mode in ['separate', 'ha'] -%}
["k8s-{{test_name}}-1", "k8s-{{test_name}}-2", "k8s-{{test_name}}-3"]
{%- else -%}
["k8s-{{test_name}}-1", "k8s-{{test_name}}-2"]
{%- endif -%}
- name: Create DO instances
digital_ocean:
unique_name: yes
api_token: "{{ lookup('env','DO_API_TOKEN') }}"
command: "droplet"
image_id: "{{ cloud_image }}"
name: "{{ item }}"
private_networking: no
region_id: "{{cloud_region}}"
size_id: 2gb
ssh_key_ids: "6536865"
state: present
wait: yes
register: droplets
with_items: "{{instance_names}}"
- debug:
msg: "{{droplets}}, {{inventory_path}}"
- name: Template the inventory
template:
src: ../templates/inventory-do.j2
dest: "{{ inventory_path }}/inventory-do.cfg"
- name: Wait for SSH to come up
wait_for: host={{item.droplet.ip_address}} port=22 delay=10 timeout=180 state=started
with_items: "{{droplets.results}}"