-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_vm.yml
56 lines (52 loc) · 1.45 KB
/
create_vm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
- name: "dhcp server : create"
local_action:
module: cs_instance
name: "{{ zone }}-{{ dhcp_name }}"
template: "{{ template }}"
root_disk_size: "{{ root_disk_size }}"
service_offering: "{{ instance_type }}"
ssh_key: "{{ ssh_key }}"
security_groups: [ '{{ security_group_name }}' ]
networks:
- "{{ private_network }}"
user_data: |
#cloud-config
manage_etc_hosts: true
fqdn: {{ zone }}-{{ dhcp_name }}
zone: "{{ zone }}"
register: privnet_dhcp
- name: "sample vms : create {{ num_nodes }} vms"
local_action:
module: cs_instance
name: "{{ zone }}-privnet-{{ item }}"
template: "{{ template }}"
root_disk_size: "{{ root_disk_size }}"
service_offering: "{{ instance_type }}"
ssh_key: "{{ ssh_key }}"
security_groups: [ '{{ security_group_name }}' ]
networks:
- "{{ private_network }}"
user_data: |
#cloud-config
manage_etc_hosts: true
fqdn: {{ zone }}-privnet-{{ item }}
zone: "{{ zone }}"
with_sequence: count={{ num_nodes }}
when: num_nodes is defined
register: infra_jobs
async: 3600
poll: 0
- name: wait for samples vms to be ready
async_status:
jid: "{{ item.ansible_job_id }}"
register: privnet_nodes
until: privnet_nodes.finished
retries: 300
with_items: "{{ infra_jobs.results }}"
when: infra_jobs is defined
- name: wait for SSH to be up
wait_for:
port: 22
host: "{{ privnet_dhcp.default_ip }}"
sleep: 5