From 9a00b67c7a2c220b47a1786d4ec4f70ee891fddf Mon Sep 17 00:00:00 2001 From: R43849 Date: Tue, 16 Jul 2024 01:33:27 +0200 Subject: [PATCH] deploy VM standalone + cluster: change tmp folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case the qcow2 file is too big for /tmp, brings back "ansible_remote_tmp" used to specify where ansible does tmp copy (very usefull for large vms). Signed-off-by: Gabin LAURENT Signed-off-by: Mathieu Dupré --- .../advanced_inventory_cluster_example.yaml | 2 ++ playbooks/deploy_vms_standalone.yaml | 10 ++++++++++ playbooks/tasks/deploy_vm.yaml | 2 ++ 3 files changed, 14 insertions(+) diff --git a/examples/inventories/advanced_inventory_cluster_example.yaml b/examples/inventories/advanced_inventory_cluster_example.yaml index 17a44de82..c41efa196 100644 --- a/examples/inventories/advanced_inventory_cluster_example.yaml +++ b/examples/inventories/advanced_inventory_cluster_example.yaml @@ -207,3 +207,5 @@ all: # The name of the user used for the livemigration # If not set, livemigration will be disabled livemigration_user: username + # qcow2tmpuploadfolder: folder to store the qcow2 file while importing a guest. + qcow2tmpuploadfolder: "/data/.ansible" diff --git a/playbooks/deploy_vms_standalone.yaml b/playbooks/deploy_vms_standalone.yaml index 9d25f51ff..8c299c02d 100644 --- a/playbooks/deploy_vms_standalone.yaml +++ b/playbooks/deploy_vms_standalone.yaml @@ -29,10 +29,20 @@ var: hostvars[item] verbosity: 2 with_items: "{{ groups['VMs'] }}" + - name: Check tmp folder permission + file: + path: "{{ qcow2tmpuploadfolder }}" + state: directory + owner: "{{ ansible_user }}" + group: "{{ ansible_user }}" + mode: '0755' + when: qcow2tmpuploadfolder is defined - name: Copy the disk on target copy: src: "{{ hostvars[item].vm_disk }}" dest: "{{ disk_pool }}/{{ hostvars[item].inventory_hostname }}.qcow2" + vars: + ansible_remote_tmp: "{{ qcow2tmpuploadfolder | default(omit) }}" with_items: "{{ groups['VMs'] }}" when: disk_copy | bool and (hostvars[item].disk_extract is not defined or not hostvars[item].disk_extract | bool) - name: Copy the gziped disk on target diff --git a/playbooks/tasks/deploy_vm.yaml b/playbooks/tasks/deploy_vm.yaml index 32c701bb6..d6034cd86 100644 --- a/playbooks/tasks/deploy_vm.yaml +++ b/playbooks/tasks/deploy_vm.yaml @@ -27,6 +27,8 @@ copy: src: "{{ vm_file }}" dest: "{{ vm_file_dest }}" + vars: + ansible_remote_tmp: "{{ qcow2tmpuploadfolder | default(omit) }}" when: disk_copy | default(true) | bool - name: "Create {{ item }}" cluster_vm: