MNAIO: Default vm_use_snapshot is group_vars
Rather than have to default it in tasks all over the place, we default it in group_vars. The default is to enable the feature if file-backed VM's are used. However, if there are no base images available, the set_fact task disables it. If a user wishes to force it not to be used, then an extra-var override is still usable. Change-Id: I5c916244a02a44da831d2a0fefd8e8aafae829b2
This commit is contained in:
parent
80eae4a185
commit
934a3c2651
@ -93,11 +93,9 @@
|
|||||||
patterns: '*-base.img'
|
patterns: '*-base.img'
|
||||||
register: _base_images
|
register: _base_images
|
||||||
|
|
||||||
- name: Set vm_use_snapshot if it's not defined
|
- name: Enable/disable vm_use_snapshot based on whether there are base image files
|
||||||
set_fact:
|
set_fact:
|
||||||
vm_use_snapshot: "{{ _base_images['matched'] > 0 }}"
|
vm_use_snapshot: "{{ _base_images['matched'] > 0 }}"
|
||||||
when:
|
|
||||||
- vm_use_snapshot is not defined
|
|
||||||
|
|
||||||
- name: Clean up base image files if they are not being used
|
- name: Clean up base image files if they are not being used
|
||||||
file:
|
file:
|
||||||
@ -132,7 +130,7 @@
|
|||||||
name: "{{ hostvars[item]['server_hostname'] }}"
|
name: "{{ hostvars[item]['server_hostname'] }}"
|
||||||
command: define
|
command: define
|
||||||
xml: >-
|
xml: >-
|
||||||
{%- if (vm_use_snapshot | default(False)) | bool %}
|
{%- if vm_use_snapshot | bool %}
|
||||||
{{ lookup('file', _virt_pools.pools.default.path | default('/data/images') ~ '/' ~ hostvars[item]['server_hostname'] ~ '.xml') }}
|
{{ lookup('file', _virt_pools.pools.default.path | default('/data/images') ~ '/' ~ hostvars[item]['server_hostname'] ~ '.xml') }}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
{{ lookup('template', 'kvm/kvm-vm.xml.j2') }}
|
{{ lookup('template', 'kvm/kvm-vm.xml.j2') }}
|
||||||
|
@ -35,6 +35,9 @@ ipxe_kernel_base_url: "http://boot.ipxe.org"
|
|||||||
# The timeout for the SSH check to the vm_servers
|
# The timeout for the SSH check to the vm_servers
|
||||||
vm_ssh_timeout: 1500
|
vm_ssh_timeout: 1500
|
||||||
|
|
||||||
|
# Whether to use snapshots (if they are available) for file-backed VM's
|
||||||
|
vm_use_snapshot: "{{ default_vm_disk_mode == 'file' }}"
|
||||||
|
|
||||||
# IP address, or domain name of the TFTP server
|
# IP address, or domain name of the TFTP server
|
||||||
tftp_server: "{{ hostvars[groups['pxe_hosts'][0]]['ansible_host'] | default(ansible_host) }}"
|
tftp_server: "{{ hostvars[groups['pxe_hosts'][0]]['ansible_host'] | default(ansible_host) }}"
|
||||||
# tftp_ssh_key: '' # user defined ssh key, used to access the host
|
# tftp_ssh_key: '' # user defined ssh key, used to access the host
|
||||||
|
Loading…
x
Reference in New Issue
Block a user