-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision_vms.yml
109 lines (96 loc) · 3.28 KB
/
provision_vms.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
- name: Provision VMs
hosts: hypervisor
gather_facts: yes
any_errors_fatal: true
vars:
appliance_version: '1.40.1'
appliance_checksum: 'sha1:525522aaf4fcc4f5212cc2a9e98ee873d125536e'
base_image_path: /var/lib/libvirt/images
url: "{{ provision.image.url }}"
infrared_vswitch_types:
- vqfx
tasks:
- name: Get uniq id for current deployment
set_fact:
prefix: "{{ ansible_local.run.keys()[0] }}"
when: provision.prefix is defined
- name: load nodes topology configuration
include_tasks: tasks/load_topology.yml
with_dict: "{{ provision.topology.nodes }}"
loop_control:
loop_var: node
- name: Get Appliance files to allow virt-customize on RHEL hypervisors
get_url:
dest: /opt/appliance-{{ appliance_version }}.tar.xz
checksum: "{{ appliance_checksum }}"
url: http://download.libguestfs.org/binaries/appliance/appliance-{{ appliance_version }}.tar.xz
register: appliance_archive
- name: Unpack Appliance files
when: appliance_archive is changed
unarchive:
src: "{{ appliance_archive.dest }}"
dest: /opt/
remote_src: yes
- name: provision image for each node
include_tasks: tasks/download_images.yml
with_dict: "{{ topology_nodes }}"
loop_control:
loop_var: node
tags: images
- name: prepare bridge interfaces in the topology
set_fact:
topology_nodes: "{{ topology_nodes | wirenodes }}"
# Create Disks
- block:
- name: create disks for each VM if not import
include_tasks: tasks/vms_1_create_disk.yml
with_dict: "{{ topology_nodes }}"
loop_control:
loop_var: node
- name: Wait for all disks to be created
async_status:
jid: "{{ item }}"
register: disk_tasks
until: disk_tasks.finished
retries: 300
with_items: "{{ async_disks }}"
tags: disks
# Build VMs
- block:
- name: define libvirt VMs
include_tasks: tasks/vms_2_install.yml
with_dict: "{{ topology_nodes }}"
loop_control:
loop_var: node
- name: Wait for VMs to be created
async_status:
jid: "{{ item }}"
register: install_tasks
until: install_tasks.finished
retries: 300
with_items: "{{ async_install }}"
tags: install
# Fetch IP addresses
- block:
- name: Get VMs hardware adresses
include_tasks: tasks/vms_3_hwaddr.yml
with_dict: "{{ topology_nodes }}"
loop_control:
loop_var: node
- name: Set ip VMs ip addresses and add to inventory
include_tasks: tasks/netip_natted.yml
when: "not topology_node.external_network.bridged|default(False)"
tags: ips
- name: Post-configure VMs
include_tasks: tasks/vms_4_post_configure.yml
with_dict: "{{ topology_nodes }}"
loop_control:
loop_var: node
# TODO(obaranov) This is deprecated config. Remove it.
- name: update tunneling conf
template:
src: ansible.ssh.config.j2
dest: "{{ inventory_dir }}/ansible.ssh.config"
delegate_to: localhost
tags: ssh_tunnel