--- - name: Check vm cloud-init ansible.builtin.stat: path: "{{ node['libvirt_path'] }}/images/debian-13.qcow2" become: true register: is_cloud_init_file - name: Deploy vm cloud-init ansible.builtin.copy: src: "{{ hostvars['console']['node']['data_path'] }}/images/debian-13-generic-amd64.qcow2" dest: "{{ node['libvirt_path'] }}/images/debian-13.qcow2" owner: "{{ ansible_user }}" group: "{{ node['group'] }}" mode: "0644" force: false become: true when: not is_cloud_init_file.stat.exists - name: Remote copy vm cloud-init file ansible.builtin.copy: src: "{{ node['libvirt_path'] }}/images/debian-13.qcow2" dest: "{{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2" owner: "{{ ansible_user }}" group: "{{ node['group'] }}" mode: "0644" remote_src: true force: false become: true - name: Check deployed cloud-init file info ansible.builtin.command: | qemu-img info {{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2 --output json changed_when: false failed_when: - deployed_cloudfile_info.rc != 0 - ("lock") not in deployed_cloudfile_info.stderr register: "deployed_cloudfile_info" - name: Resize deployed cloud-init file ansible.builtin.command: | qemu-img resize {{ node['libvirt_path'] }}/images/{{ target_vm }}.qcow2 {{ hostvars[target_vm]['vm']['storage'] }}G when: - deployed_cloudfile_info.rc == 0 - (deployed_cloudfile_info.stdout | from_json)['virtual-size'] < (hostvars[target_vm]['vm']['storage'] | int * 1024 * 1024 * 1024) changed_when: true - name: Check bk/app raw image ansible.builtin.stat: path: "{{ hardware['disk'][hostvars[target_vm]['vm']['data_storage']['pool']]['fs']['mount_point'] }}/{{ target_vm }}.raw" get_checksum: false get_mime: false get_attributes: false when: target_vm in ["bk", "app"] register: "is_app_data" - name: Create bk/app raw image ansible.builtin.command: | qemu-img create -f raw {{ hardware['disk'][hostvars[target_vm]['vm']['data_storage']['pool']]['fs']['mount_point'] }}/{{ target_vm }}.raw \ {{ hostvars[target_vm]['vm']['data_storage']['size'] }}T become: true when: - target_vm in ["bk", "app"] - not is_app_data.stat.exists changed_when: true - name: Deploy vm seed.iso ansible.builtin.copy: src: "{{ hostvars['console']['node']['data_path'] }}/images/seeds/{{ target_vm }}/seed.iso" dest: "{{ node['libvirt_path'] }}/seeds/{{ target_vm }}_seed.iso" owner: "{{ ansible_user }}" group: "{{ node['group'] }}" mode: "0644" become: true when: deployed_cloudfile_info.rc == 0