blob: d33ebccd560df23819391f0d4e88e732985066d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
- name: Copy kickstart file to destination filesystem (if defined)
ansible.builtin.template:
src: "kickstart/{{ libvirt_vm_kickstart_file }}"
dest: "/{{ libvirt_vm_destination }}/{{ libvirt_vm_kickstart_file }}"
mode: '0644'
when: libvirt_vm_kickstart_file | length > 0
- name: Create VM from kickstart in destination filesystem
ansible.builtin.command: 'virt-install --name {{ libvirt_vm_name }} --graphics vnc --memory {{ libvirt_vm_memory }} --vcpus {{ libvirt_vm_vcpus }} --network {{ libvirt_vm_network }} --disk size={{ libvirt_vm_disk_size }},path=/{{ libvirt_vm_destination }}/{{ libvirt_vm_name }}.img,format={{ libvirt_vm_disk_format }} --location {{ libvirt_vm_location_path }}{{ libvirt_vm_location_arguments }} --os-variant {{ libvirt_vm_os }} --cpu {{ libvirt_vm_cpu }} --initrd-inject=/{{ libvirt_vm_destination }}/{{ libvirt_vm_kickstart_file }} --extra-args="inst.ks=file:/{{ libvirt_vm_kickstart_file }}"'
when: libvirt_vm_kickstart_file | length > 0
- name: Create VM without kickstart in destination filesystem
ansible.builtin.command: 'virt-install --name {{ libvirt_vm_name }} --graphics vnc --memory {{ libvirt_vm_memory }} --vcpus {{ libvirt_vm_vcpus }} --network {{ libvirt_vm_network }} --disk size={{ libvirt_vm_disk_size }},path=/{{ libvirt_vm_destination }}/{{ libvirt_vm_name }}.img,format={{ libvirt_vm_disk_format }} --cdrom {{ libvirt_vm_location_path }} --os-variant {{ libvirt_vm_os }} --cpu {{ libvirt_vm_cpu }}'
when: libvirt_vm_kickstart_file | length == 0
- name: Remove kickstart file from destination filesystem (if defined)
ansible.builtin.file:
path: "/{{ libvirt_vm_destination }}/{{ libvirt_vm_kickstart_file }}"
state: absent
when: libvirt_vm_kickstart_file | length > 0
|