回答編集履歴
1
追記
test
CHANGED
@@ -61,3 +61,85 @@
|
|
61
61
|
var: res.results | map(attribute='ansible_facts') | list
|
62
62
|
|
63
63
|
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
---
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
ループの中身を別ファイルにして set_fact で vm_disk を作るほうがまだは判りやすいかもしれません・・
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
```yaml
|
76
|
+
|
77
|
+
# main.yaml
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
- include: deploy.yaml
|
82
|
+
|
83
|
+
with_items: "{{ vms }}"
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```yaml
|
90
|
+
|
91
|
+
# deploy.yaml
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
- set_fact:
|
96
|
+
|
97
|
+
vm_disk:
|
98
|
+
|
99
|
+
disk1:
|
100
|
+
|
101
|
+
size_gd: "{{ item.disk1_disksize }}"
|
102
|
+
|
103
|
+
type: thin
|
104
|
+
|
105
|
+
datastore: "{{ item.disk1_datastore_name }}"
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
- set_fact:
|
110
|
+
|
111
|
+
vm_disk:
|
112
|
+
|
113
|
+
disk1: "{{ vm_disk.disk1 }}"
|
114
|
+
|
115
|
+
disk2:
|
116
|
+
|
117
|
+
size_gd: "{{ item.disk2_disksize }}"
|
118
|
+
|
119
|
+
type: thin
|
120
|
+
|
121
|
+
datastore: "{{ item.disk2_datastore_name }}"
|
122
|
+
|
123
|
+
when: item.disk2_disksize is defined
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
- name: Deploy guest VMs
|
128
|
+
|
129
|
+
set_fact:
|
130
|
+
|
131
|
+
vsphere_guest:
|
132
|
+
|
133
|
+
vcenter_hostname: "{{ esx_ipaddr }}"
|
134
|
+
|
135
|
+
vm_disk: "{{ vm_disk }}"
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
# 確認用
|
140
|
+
|
141
|
+
- debug:
|
142
|
+
|
143
|
+
var: vsphere_guest
|
144
|
+
|
145
|
+
```
|