This commit is contained in:
parent
b763d2b562
commit
e89505bef6
@ -50,6 +50,13 @@
|
|||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
|
- name: Check for existing templates on hypervisor
|
||||||
|
community.vmware.vmware_guest_info:
|
||||||
|
name: "{{ (item | basename | split('.'))[:-1] | join('.') }}"
|
||||||
|
register: existing_ova
|
||||||
|
with_fileglob: /opt/workloadcluster/node-templates/*.ova
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: Parse OVA files for network mappings
|
- name: Parse OVA files for network mappings
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: govc import.spec -json {{ item }}
|
cmd: govc import.spec -json {{ item }}
|
||||||
@ -59,36 +66,41 @@
|
|||||||
GOVC_USERNAME: "{{ vapp['hv.username'] }}"
|
GOVC_USERNAME: "{{ vapp['hv.username'] }}"
|
||||||
GOVC_PASSWORD: "{{ vapp['hv.password'] }}"
|
GOVC_PASSWORD: "{{ vapp['hv.password'] }}"
|
||||||
register: ova_spec
|
register: ova_spec
|
||||||
|
when: existing_ova.results[index] is failed
|
||||||
with_fileglob: /opt/workloadcluster/node-templates/*.ova
|
with_fileglob: /opt/workloadcluster/node-templates/*.ova
|
||||||
|
loop_control:
|
||||||
|
index_var: index
|
||||||
|
|
||||||
- name: Deploy OVA templates on hypervisor
|
- name: Deploy OVA templates on hypervisor
|
||||||
community.vmware.vmware_deploy_ovf:
|
community.vmware.vmware_deploy_ovf:
|
||||||
hostname: "{{ vapp['hv.fqdn'] }}"
|
|
||||||
validate_certs: no
|
|
||||||
username: "{{ vapp['hv.username'] }}"
|
|
||||||
password: "{{ vapp['hv.password'] }}"
|
|
||||||
datacenter: "{{ vcenter_info.datacenter }}"
|
|
||||||
cluster: "{{ vcenter_info.cluster }}"
|
cluster: "{{ vcenter_info.cluster }}"
|
||||||
datastore: "{{ vcenter_info.datastore }}"
|
datastore: "{{ vcenter_info.datastore }}"
|
||||||
folder: "{{ vcenter_info.folder }}"
|
folder: "{{ vcenter_info.folder }}"
|
||||||
|
name: "{{ (item | basename | split('.'))[:-1] | join('.') }}"
|
||||||
networks: "{u'{{ ova_spec.results[index].stdout | from_json | json_query('NetworkMapping[0].Name') }}':u'{{ vcenter_info.network }}'}"
|
networks: "{u'{{ ova_spec.results[index].stdout | from_json | json_query('NetworkMapping[0].Name') }}':u'{{ vcenter_info.network }}'}"
|
||||||
allow_duplicates: no
|
allow_duplicates: no
|
||||||
power_on: false
|
power_on: false
|
||||||
ovf: "{{ item }}"
|
ovf: "{{ item }}"
|
||||||
register: ova_deploy
|
register: ova_deploy
|
||||||
|
when: existing_ova.results[index] is failed
|
||||||
with_fileglob: /opt/workloadcluster/node-templates/*.ova
|
with_fileglob: /opt/workloadcluster/node-templates/*.ova
|
||||||
loop_control:
|
loop_control:
|
||||||
index_var: index
|
index_var: index
|
||||||
|
|
||||||
- name: Mark deployed VM's as templates
|
- name: Mark deployed VM's as templates
|
||||||
community.vmware.vmware_guest:
|
community.vmware.vmware_guest:
|
||||||
|
name: "{{ item.instance.hw_name }}"
|
||||||
|
is_template: yes
|
||||||
|
when: ova_deploy.results[index] is not skipped
|
||||||
|
loop: "{{ ova_deploy.results }}"
|
||||||
|
loop_control:
|
||||||
|
index_var: index
|
||||||
|
label: "{{ item.item }}"
|
||||||
|
|
||||||
|
module_defaults:
|
||||||
|
group/vmware:
|
||||||
hostname: "{{ vapp['hv.fqdn'] }}"
|
hostname: "{{ vapp['hv.fqdn'] }}"
|
||||||
validate_certs: no
|
validate_certs: no
|
||||||
username: "{{ vapp['hv.username'] }}"
|
username: "{{ vapp['hv.username'] }}"
|
||||||
password: "{{ vapp['hv.password'] }}"
|
password: "{{ vapp['hv.password'] }}"
|
||||||
datacenter: "{{ vcenter_info.datacenter }}"
|
datacenter: "{{ vcenter_info.datacenter }}"
|
||||||
name: "{{ item.instance.hw_name }}"
|
|
||||||
is_template: yes
|
|
||||||
loop: "{{ ova_deploy.results }}"
|
|
||||||
loop_control:
|
|
||||||
label: "{{ item.instance.moid }}"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user