Skip to content

Commit

Permalink
deploy VM standalone + cluster: change tmp folder
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Mathieu Dupré <[email protected]>
  • Loading branch information
Gabin-rte authored and dupremathieu committed Jul 18, 2024
1 parent 9ceeb48 commit 9a00b67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/inventories/advanced_inventory_cluster_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 10 additions & 0 deletions playbooks/deploy_vms_standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions playbooks/tasks/deploy_vm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9a00b67

Please sign in to comment.