-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook_multi.yml
48 lines (43 loc) · 1.54 KB
/
playbook_multi.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
---
- name: Playbook to kick off a mass migration from vmware to ocp-virt
hosts: localhost
vars:
# max number of users created. use -e ceiling=10 for 10 users
ceiling: 100
provision_data_file: "{{ playbook_dir }}/provision_data.yaml"
resource_state: present
collections:
- rlopez.ocp_virt
# roles:
# - {role: rlopez.ocp_virt.validation}
# - {role: rlopez.ocp_virt.providers}
# - {role: rlopez.ocp_virt.virt_plan}
tasks:
- name: Debug resource state
ansible.builtin.debug:
msg: "{{ resource_state }}"
- name: Load in provision data
ansible.builtin.include_vars:
file: "{{ provision_data_file }}"
- name: Debug provision data
ansible.builtin.debug:
msg: "{{ provision_data }}"
- block:
- name: Loop over users, including the tasks
when: my_idx < ceiling | int
vars:
_user_name: "{{ _user.value.user }}"
_user_password: "{{ _user.value.password }}"
vcenter_hostname: "{{ _user.value.vcenter_console}}"
vcenter_password: "{{ _user.value.vcenter_password }}"
vcenter_username: "{{ _user.value.vcenter_full_user }}"
ansible.builtin.include_tasks:
file: kick_off_migration.yaml
loop: "{{ provision_data.users | dict2items }}"
loop_control:
index_var: my_idx
loop_var: _user
label: "{{ _user.key }}"
- name: Stop execution of this playbook
ansible.builtin.fail:
msg: "Stop right there!"