Skip to content

Commit

Permalink
playbooks/tasks/deploy_vm.yaml: change default value
Browse files Browse the repository at this point in the history
* disk_copy is true by default
* live_migration is false by default instead of empty string
* vm_file and vm_file_dest are defined in the taks instead of the
  playbook
* Remove ansible_remote_tmp variable

Signed-off-by: Mathieu Dupré <[email protected]>
  • Loading branch information
dupremathieu committed Jul 5, 2024
1 parent 9881b71 commit 04e798c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 0 additions & 4 deletions playbooks/deploy_vms_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
- name: "Deploy VMs"
include_tasks: tasks/deploy_vm.yaml
loop: "{{ groups['VMs'] }}"
vars:
disk_copy: true
vm_file: "{{ hostvars[item].vm_disk | default( (vms_disks_directory|default('')) ~ '/' ~ item ~ '.qcow2') }}"
vm_file_dest: "{{ qcow2tmpuploadfolder | default('/tmp') + '/os.qcow2' }}"
- name: "Define colocation constraints"
include_tasks: tasks/colocation.yaml
loop: "{{ groups['VMs'] }}"
11 changes: 7 additions & 4 deletions playbooks/tasks/deploy_vm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (C) 2021, RTE (http://www.rte-france.com)
# Copyright (C) 2024 Savoir-faire Linux, Inc
# SPDX-License-Identifier: Apache-2.0
# Task to deploy a VM

Expand Down Expand Up @@ -26,16 +27,14 @@
copy:
src: "{{ vm_file }}"
dest: "{{ vm_file_dest }}"
vars:
ansible_remote_tmp: "{{ qcow2tmpuploadfolder | default(omit) }}"
when: disk_copy | bool
when: disk_copy | default(true) | bool
- name: "Create {{ item }}"
cluster_vm:
name: "{{ item }}"
command: create
system_image: "{{ vm_file_dest }}"
force: true
live_migration: "{{ hostvars[item].live_migration | default('') }}"
live_migration: "{{ hostvars[item].live_migration | default(false) }}"
migration_user: "{{ livemigration_user | default(omit) }}"
migrate_to_timeout: "{{ hostvars[item].migrate_to_timeout | default(omit) }}"
migration_downtime: "{{ hostvars[item].migration_downtime | default(omit) }}"
Expand All @@ -61,4 +60,8 @@
when:
- hostvars[item].wait_for_connection is defined
- hostvars[item].wait_for_connection
vars:
vm_file: "{{ hostvars[item].vm_disk | default( (vms_disks_directory|default('')) ~ '/' ~ item ~ '.qcow2') }}"
vm_file_dest: "{{ qcow2tmpuploadfolder | default('/tmp') + '/os.qcow2' }}"

when: presencevm.status == "Undefined" or (hostvars[item].force is defined and hostvars[item].force)

0 comments on commit 04e798c

Please sign in to comment.