2022-04-18 10:58:57 +00:00
|
|
|
- hosts: localhost
|
|
|
|
gather_facts: false
|
|
|
|
vars_files:
|
2022-04-18 12:28:05 +00:00
|
|
|
- hypervisor.vcenter.yml
|
2022-04-18 19:35:28 +00:00
|
|
|
- cluster.k3s.yml
|
2022-04-18 10:58:57 +00:00
|
|
|
tasks:
|
2022-04-19 10:07:26 +00:00
|
|
|
|
2022-04-19 07:10:44 +00:00
|
|
|
- name: Download OVF-template
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "https://{{ repo_username }}:{{ repo_password }}@{{ image.ova_url }}"
|
|
|
|
dest: /scratch/image.ova
|
2022-04-19 10:07:26 +00:00
|
|
|
|
2022-04-18 20:49:50 +00:00
|
|
|
- name: Deploy VMs from OVF-template
|
|
|
|
community.vmware.vmware_deploy_ovf:
|
2022-04-18 12:28:05 +00:00
|
|
|
hostname: "{{ hv.hostname }}"
|
|
|
|
username: "{{ hv.username }}"
|
|
|
|
password: "{{ hv_password }}"
|
2022-04-18 10:58:57 +00:00
|
|
|
validate_certs: no
|
2022-04-18 12:28:05 +00:00
|
|
|
datacenter: "{{ hv.datacenter }}"
|
|
|
|
folder: "{{ hv.folder }}"
|
|
|
|
cluster: "{{ hv.cluster }}"
|
2022-04-19 07:53:20 +00:00
|
|
|
name: "{{ kubernetes.clustername | upper }}-{{ (item.ip | checksum)[-5:] | upper }}"
|
2022-04-18 20:49:50 +00:00
|
|
|
datastore: "{{ hv.datastore }}"
|
2022-04-18 21:08:48 +00:00
|
|
|
disk_provisioning: thin
|
|
|
|
networks:
|
|
|
|
"LAN": "{{ hv.network }}"
|
2022-04-18 20:49:50 +00:00
|
|
|
power_on: yes
|
2022-04-19 07:10:44 +00:00
|
|
|
ovf: /scratch/image.ova
|
2022-04-18 21:08:48 +00:00
|
|
|
deployment_option: "{{ image.deployment_option }}"
|
|
|
|
properties:
|
2022-04-19 07:53:20 +00:00
|
|
|
guestinfo.hostname: "{{ kubernetes.clustername | upper }}-{{ (item.ip | checksum)[-5:] | upper }}"
|
2022-04-18 21:08:48 +00:00
|
|
|
guestinfo.rootpw: "{{ root_password }}"
|
|
|
|
guestinfo.rootsshkey: "foo"
|
2022-04-19 07:53:20 +00:00
|
|
|
guestinfo.ntpserver: "{{ network.ntpserver }}"
|
2022-04-18 21:12:30 +00:00
|
|
|
guestinfo.ipaddress: "{{ item.ip | ansible.utils.ipaddr('address') }}"
|
2022-04-19 08:45:18 +00:00
|
|
|
guestinfo.prefixlength: "{{ item.ip | ansible.utils.ipaddr('prefix') }}"
|
2022-04-19 07:53:20 +00:00
|
|
|
guestinfo.dnsserver: "{{ network.dnsserver }}"
|
|
|
|
guestinfo.gateway: "{{ network.gateway }}"
|
2022-04-18 12:28:05 +00:00
|
|
|
delegate_to: localhost
|
2022-04-18 10:58:57 +00:00
|
|
|
with_items: "{{ servers }}"
|
2022-04-19 10:07:26 +00:00
|
|
|
register: job_init
|
2022-04-19 10:22:56 +00:00
|
|
|
async: 300
|
2022-04-19 10:07:26 +00:00
|
|
|
poll: 0
|
|
|
|
|
|
|
|
- name: Poll for completion
|
|
|
|
ansible.builtin.async_status:
|
2022-04-19 10:12:15 +00:00
|
|
|
jid: "{{ item.ansible_job_id }}"
|
2022-04-19 10:07:26 +00:00
|
|
|
with_items: "{{ job_init.results }}"
|
|
|
|
register: job_poll
|
|
|
|
retries: 5
|
2022-04-19 10:22:56 +00:00
|
|
|
delay: 100
|
2022-04-19 10:07:26 +00:00
|
|
|
until: job_poll.finished
|
|
|
|
|
2022-04-19 08:45:18 +00:00
|
|
|
- ansible.builtin.debug:
|
2022-04-19 10:12:15 +00:00
|
|
|
var: job_poll
|