community.kubevirt.kubevirt_preset module – Manage KubeVirt virtual machine presets
Note
This module is part of the community.kubevirt collection (version 1.0.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.kubevirt
.
To use it in a playbook, specify: community.kubevirt.kubevirt_preset
.
Requirements
The below requirements are needed on the host that executes this module.
openshift >= 0.8.2
python >= 2.7
Parameters
Parameter |
Comments |
---|---|
Describes node affinity scheduling rules for the vm. |
|
If the affinity requirements specified by this field are not met at scheduling time, the vm will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during vm execution (e.g. due to a vm label update), the system may or may not try to eventually evict the vm from its node. When there are multiple elements, the lists of nodes corresponding to each |
|
The scheduler will prefer to schedule vms to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding |
|
Describes vm anti-affinity scheduling rules e.g. avoid putting this vm in the same node, zone, etc. as some other vms. |
|
If the anti-affinity requirements specified by this field are not met at scheduling time, the vm will not be scheduled onto the node. If the anti-affinity requirements specified by this field cease to be met at some point during vm execution (e.g. due to a vm label update), the system may or may not try to eventually evict the vm from its node. When there are multiple elements, the lists of nodes corresponding to each |
|
The scheduler will prefer to schedule vms to nodes that satisfy the anti-affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling anti-affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding |
|
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable. |
|
Specify the bootloader of the virtual machine. All virtual machines use BIOS by default for booting. |
|
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable. |
|
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable. |
|
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable. |
|
Represents a cloud-init NoCloud user-data source. The NoCloud data will be added as a disk to the virtual machine. A proper cloud-init installation is required inside the guest. More information https://kubevirt.io/api-reference/master/definitions.html#_v1_cloudinitnocloudsource |
|
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable. |
|
Number of CPU cores. |
|
List of dictionary to fine-tune features provided by the selected CPU model. Note: Policy attribute can either be omitted or contain one of the following policies: force, require, optional, disable, forbid. Note: In case a policy is omitted for a feature, it will default to require. More information about policies: https://libvirt.org/formatdomain.html#elementsCPU |
|
Is converted to its millicore value and multiplied by 100. The resulting value is the total amount of CPU time that a container can use every 100ms. A virtual machine cannot use more than its share of CPU time during this interval. |
|
CPU model. You can check list of available models here: https://github.com/libvirt/libvirt/blob/master/src/cpu_map/index.xml. Note: User can define default CPU model via as default-cpu-model in kubevirt-config ConfigMap, if not set host-model is used. Note: Be sure that node CPU model where you run a VM, has the same or higher CPU family. Note: If CPU model wasn’t defined, the VM will have CPU model closest to one that used on the node where the VM is running. |
|
Specify CPU shares. |
|
List of dictionaries which specify disks of the virtual machine. A disk can be made accessible via four different types: disk, lun, cdrom, floppy. All possible configuration options are available in https://kubevirt.io/api-reference/master/definitions.html#_v1_disk Each disk must have specified a volume that declares which volume type of the disk All possible configuration options of volume are available in https://kubevirt.io/api-reference/master/definitions.html#_v1_volume. |
|
If set to Choices:
|
|
Specify if the virtual machine should have attached a minimal Video and Graphics device configuration. By default a minimal Video and Graphics device configuration will be applied to the VirtualMachineInstance. The video device is vga compatible and comes with a memory size of 16 MB. |
|
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable. |
|
Specifies the hostname of the virtual machine. The hostname will be set either by dhcp, cloud-init if configured or virtual machine name will be used. |
|
Specify huge page size. |
|
Group(s) to impersonate for the operation. Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: Group1,Group2 |
|
Username to impersonate for the operation. Can also be specified via K8S_AUTH_IMPERSONATE_USER environment. |
|
An interface defines a virtual network interface of a virtual machine (also called a frontend). All possible configuration options interfaces are available in https://kubevirt.io/api-reference/master/definitions.html#_v1_interface Each interface must have specified a network that declares which logical or physical device it is connected to (also called as backend). All possible configuration options of network are available in https://kubevirt.io/api-reference/master/definitions.html#_v1_network. |
|
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from ~/.kube/config. Can also be specified via K8S_AUTH_KUBECONFIG environment variable. The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version >= 17.17.0. Added in version 2.2.0. |
|
Labels are key/value pairs that are attached to virtual machines. Labels are intended to be used to specify identifying attributes of virtual machines that are meaningful and relevant to users, but do not directly imply semantics to the core system. Labels can be used to organize and to select subsets of virtual machines. Labels can be attached to virtual machines at creation time and subsequently added and modified at any time. More on labels that are used for internal implementation https://kubevirt.io/user-guide/#/misc/annotations_and_labels |
|
QEMU machine type is the actual chipset of the virtual machine. |
|
The amount of memory to be requested by virtual machine. For example 1024Mi. |
|
The maximum memory to be used by virtual machine. For example 1024Mi. |
|
Whether to override the default patch merge approach with a specific type. If more than one merge type is given, the merge types will be tried in order. Defaults to Choices:
|
|
Name of the virtual machine preset. |
|
Namespace where the virtual machine preset exists. |
|
The comma separated list of hosts/domains/IP/CIDR that shouldn’t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable. Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY). This feature requires kubernetes>=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct. example value is “localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16” |
|
Describes vm affinity scheduling rules e.g. co-locate this vm in the same node, zone, etc. as some other vms |
|
If the affinity requirements specified by this field are not met at scheduling time, the vm will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during vm execution (e.g. due to an update), the system may or may not try to eventually evict the vm from its node. |
|
The scheduler will prefer to schedule vms to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding |
|
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable. Please read the description of the |
|
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable. When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file. Default to false. Please note that the current version of the k8s python client library does not support setting this flag to True yet. The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169 Choices:
|
|
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable. Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY). |
|
The Header used for the HTTP proxy. Documentation can be found here https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight%3Dproxy_headers#urllib3.util.make_headers. |
|
Colon-separated username:password for basic authentication header. Can also be specified via K8S_AUTH_PROXY_HEADERS_BASIC_AUTH environment. |
|
Colon-separated username:password for proxy basic authentication header. Can also be specified via K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH environment. |
|
String representing the user-agent you want, such as foo/1.0. Can also be specified via K8S_AUTH_PROXY_HEADERS_USER_AGENT environment. |
|
A partial YAML definition of the object being created/updated. Here you can define Kubernetes resource parameters not covered by this module’s parameters. NOTE: resource_definition has lower priority than module parameters. If you try to define e.g. metadata.namespace here, that value will be ignored and namespace used instead. |
|
Selector is a label query over a set of virtual machine preset. |
|
In order to provide a consistent view on the virtualized hardware for the guest OS, the SMBIOS UUID can be set. |
|
Create or delete virtual machine presets. Choices:
|
|
If specified, the fully qualified virtual machine hostname will be hostname.subdomain.namespace.svc.cluster_domain. If not specified, the virtual machine will not have a domain name at all. The DNS entry will resolve to the virtual machine, no matter if the virtual machine itself can pick up a hostname. |
|
Specify tablets to be used as input devices |
|
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable. Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need. |
|
Whether or not to verify the API server’s SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable. Choices:
|
|
True if the module should wait for the resource to get into desired state. Choices:
|
|
Number of seconds to sleep between checks. Default: 5 |
|
The amount of time in seconds the module should wait for the resource to get into desired state. Default: 120 |
Notes
Note
To avoid SSL certificate validation errors when
validate_certs
is True, the full certificate chain for the API server must be provided viaca_cert
or in the kubeconfig file.In order to use this module you have to install Openshift Python SDK. To ensure it’s installed with correct version you can create the following task: pip: name=openshift>=0.8.2
Examples
- name: Create virtual machine preset 'vmi-preset-small'
community.kubevirt.kubevirt_preset:
state: present
name: vmi-preset-small
namespace: vms
memory: 64M
selector:
matchLabels:
kubevirt.io/vmPreset: vmi-preset-small
- name: Remove virtual machine preset 'vmi-preset-small'
community.kubevirt.kubevirt_preset:
state: absent
name: vmi-preset-small
namespace: vms
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The virtual machine preset managed by the user. This dictionary contains all values returned by the KubeVirt API all options are described here https://kubevirt.io/api-reference/master/definitions.html#_v1_virtualmachineinstancepreset Returned: success |
Authors
KubeVirt Team (@kubevirt)