-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.yml
237 lines (207 loc) · 7.4 KB
/
main.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
---
# tasks file for provision
## Ovirt Module Start ####
- block:
- name: Include oVirt password
no_log: true
include_vars: ../vars/main.yml
- name: Obtain SSO token
ovirt_auth:
url: "{{ engine_url }}"
username: "{{ username }}"
password: "{{ password }}"
ca_file: "{{ engine_cafile }}"
## Start creating control node ##
- name: Create Control VM from {{ template }}
ovirt_vms:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
template: "{{ template }}"
cluster: "{{ cluster }}"
type: server
cpu_cores: 2
cpu_sockets: 2
memory: "{{ control_mem }}"
high_availability: true
operating_system: rhel_7x64
state: running
cloud_init:
host_name: "{{ item }}"
user_name: root
root_password: '{{ root_password }}'
authorized_ssh_keys: "{{ ssh_key }}"
cloud_init_nics:
- nic_name: "{{ nic1 }}"
nic_boot_protocol: static
nic_ip_address: "{{ ip_ctl }}"
nic_netmask: "{{ netmask }}"
nic_gateway: "{{ gateway }}"
nic_on_boot: true
- nic_name: "{{ nic2 }}"
nic_boot_protocol: static
nic_ip_address: "{{ priv_ctl }}"
nic_netmask: 255.255.255.0
nic_on_boot: true
with_items:
- "{{ ctl_name }}"
- name: Add additiona nic.
# Add NIC to VM
ovirt_nics:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
state: present
vm: "{{ item }}"
name: nic2
interface: virtio
#mac_address: 00:1b:4a:16:01:56
profile: ovirtmgmt
network: ovirtmgmt
with_items:
- "{{ ctl_name }}"
## End of creating Control node ##
## Start creating Network node ##
- name: Create Network VM from {{ template }}
ovirt_vms:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
template: "{{ template }}"
cluster: "{{ cluster }}"
type: server
cpu_cores: 1
cpu_sockets: 1
memory: "{{ network_mem }}"
high_availability: true
operating_system: rhel_7x64
state: running
cloud_init:
host_name: "{{ item }}"
user_name: root
root_password: '{{ root_password }}'
authorized_ssh_keys: "{{ ssh_key }}"
cloud_init_nics:
- nic_name: "{{ nic1 }}"
nic_boot_protocol: static
nic_ip_address: "{{ ip_network }}"
nic_netmask: "{{ netmask }}"
nic_gateway: "{{ gateway }}"
nic_on_boot: true
- nic_name: "{{ nic2 }}"
nic_boot_protocol: static
nic_ip_address: "{{ priv_network }}"
nic_netmask: 255.255.255.0
nic_on_boot: true
with_items:
- "{{ network_name }}"
- name: Add additiona nic.
# Add NIC to VM
ovirt_nics:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
state: present
vm: "{{ item }}"
name: nic2
interface: virtio
#mac_address: 00:1b:4a:16:01:56
profile: ovirtmgmt
network: ovirtmgmt
with_items:
- "{{ network_name }}"
## End of creating Network node ##
## Start creating compute node ##
- name: Create Compute VM from {{ template }}
ovirt_vms:
auth: "{{ ovirt_auth }}"
name: "{{ item.node }}"
template: "{{ template }}"
cluster: "{{ cluster }}"
type: server
cpu_cores: 2
cpu_sockets: 2
memory: "{{ compute_mem }}"
high_availability: true
operating_system: rhel_7x64
state: running
cloud_init:
host_name: "{{ item.node }}"
user_name: root
root_password: '{{ root_password }}'
authorized_ssh_keys: "{{ ssh_key }}"
cloud_init_nics:
- nic_name: "{{ nic1 }}"
nic_boot_protocol: static
nic_ip_address: "{{ item.ip }} "
nic_netmask: "{{ netmask }}"
nic_gateway: "{{ gateway }}"
nic_on_boot: true
- nic_name: "{{ nic2 }}"
nic_boot_protocol: static
nic_ip_address: "{{ item.ip_priv }}"
nic_netmask: 255.255.255.0
nic_on_boot: true
with_items:
- { node: "{{ comp01_name }}", ip: "{{ ip_compute01 }}", ip_priv: "{{ priv_compute01 }}" }
- { node: "{{ comp02_name }}", ip: "{{ ip_compute02 }}", ip_priv: "{{ priv_compute02 }}" }
- name: Add additiona nic.
# Add NIC to VM
ovirt_nics:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
state: present
vm: "{{ item }}"
name: nic2
interface: virtio
#mac_address: 00:1b:4a:16:01:56
profile: ovirtmgmt
network: ovirtmgmt
with_items:
- compute01.rhlabs.org
- compute02.rhlabs.org
## End of creating Compute node ##
## Start creating Ceph node ##
- name: Create Ceph VM from {{ template }}
ovirt_vms:
auth: "{{ ovirt_auth }}"
name: "{{ item.node }}"
template: "{{ template }}"
cluster: "{{ cluster }}"
type: server
cpu_cores: 1
cpu_sockets: 1
memory: "{{ ceph_mem }}"
high_availability: true
operating_system: rhel_7x64
state: running
cloud_init:
host_name: "{{ item.node }}"
user_name: root
root_password: '{{ root_password }}'
authorized_ssh_keys: "{{ ssh_key }}"
cloud_init_nics:
- nic_name: "{{ nic1 }}"
nic_boot_protocol: static
nic_ip_address: "{{ item.ip }} "
nic_netmask: "{{ netmask }}"
nic_gateway: "{{ gateway }}"
nic_on_boot: true
with_items:
- { node: "{{ ceph01_name }}", ip: "{{ ip_ceph01 }}" }
- { node: "{{ ceph02_name }}", ip: "{{ ip_ceph02 }}" }
- ovirt_disks:
auth: "{{ ovirt_auth }}"
state: attached
name: "{{ item }}"
vm_name: "{{ item }}"
size: 50GiB
format: cow
interface: virtio
storage_domain: Images
with_items:
- "{{ ceph01_name }}"
- "{{ ceph02_name }}"
## End of creating Ceph node ##
always:
- name: Revoke the SSO token
ovirt_auth:
state: absent
ovirt_auth: "{{ ovirt_auth }}"
#### Ovirt Module End #####