
.. Document meta

:orphan:

.. |antsibull-internal-nbsp| unicode:: 0xA0
    :trim:

.. meta::
  :antsibull-docs: 2.12.0

.. Anchors

.. _ansible_collections.kubevirt.core.kubevirt_vm_module:

.. Anchors: short name for ansible.builtin

.. Title

kubevirt_vm -- Create or delete KubeVirt VirtualMachines
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.. Collection note

.. note::
    This module is part of the `kubevirt.core collection <https://galaxy.ansible.com/ui/repo/published/kubevirt/core/>`_.

    It is not included in ``ansible-core``.
    To check whether it is installed, run :code:`ansible-galaxy collection list`.

    To install it, use: :code:`ansible-galaxy collection install kubevirt.core`.
    You need further requirements to be able to use this module,
    see :ref:`Requirements <ansible_collections.kubevirt.core.kubevirt_vm_module_requirements>` for details.

    To use it in a playbook, specify: :code:`kubevirt.core.kubevirt_vm`.

.. version_added


.. contents::
   :local:
   :depth: 1

.. Deprecated


Synopsis
--------

.. Description

- Use the Kubernetes Python client to perform create or delete operations on KubeVirt VirtualMachines.
- Pass options to create the VirtualMachine as module arguments.
- Authenticate using either a config file, certificates, password or token.
- Supports check mode.


.. Aliases


.. Requirements

.. _ansible_collections.kubevirt.core.kubevirt_vm_module_requirements:

Requirements
------------
The below requirements are needed on the host that executes this module.

- python \>= 3.9
- kubernetes \>= 28.1.0
- PyYAML \>= 3.11
- jsonpatch






.. Options

Parameters
----------

.. raw:: html

  <table class="colwidths-auto ansible-option-table docutils align-default" style="width: 100%">
  <thead>
  <tr class="row-odd">
    <th class="head"><p>Parameter</p></th>
    <th class="head"><p>Comments</p></th>
  </tr>
  </thead>
  <tbody>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-annotations"></div>
      <p class="ansible-option-title"><strong>annotations</strong></p>
      <a class="ansibleOptionLink" href="#parameter-annotations" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify annotations to set on the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>Only used when <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-api_key"></div>
      <p class="ansible-option-title"><strong>api_key</strong></p>
      <a class="ansibleOptionLink" href="#parameter-api_key" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Token used to authenticate with the API.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_API_KEY</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-api_version"></div>
      <p class="ansible-option-title"><strong>api_version</strong></p>
      <a class="ansibleOptionLink" href="#parameter-api_version" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Use this to set the API version of KubeVirt.</p>
      <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-value literal notranslate ansible-option-default">&#34;kubevirt.io/v1&#34;</code></p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-ca_cert"></div>
      <div class="ansibleOptionAnchor" id="parameter-ssl_ca_cert"></div>
      <p class="ansible-option-title"><strong>ca_cert</strong></p>
      <a class="ansibleOptionLink" href="#parameter-ca_cert" title="Permalink to this option"></a>
      <p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: ssl_ca_cert</span></p>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">path</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_SSL_CA_CERT</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-client_cert"></div>
      <div class="ansibleOptionAnchor" id="parameter-cert_file"></div>
      <p class="ansible-option-title"><strong>client_cert</strong></p>
      <a class="ansibleOptionLink" href="#parameter-client_cert" title="Permalink to this option"></a>
      <p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: cert_file</span></p>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">path</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Path to a certificate used to authenticate with the API.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_CERT_FILE</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-client_key"></div>
      <div class="ansibleOptionAnchor" id="parameter-key_file"></div>
      <p class="ansible-option-title"><strong>client_key</strong></p>
      <a class="ansibleOptionLink" href="#parameter-client_key" title="Permalink to this option"></a>
      <p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: key_file</span></p>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">path</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Path to a key file used to authenticate with the API.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_KEY_FILE</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-context"></div>
      <p class="ansible-option-title"><strong>context</strong></p>
      <a class="ansibleOptionLink" href="#parameter-context" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>The name of a context found in the config file.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_CONTEXT</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-data_volume_templates"></div>
      <p class="ansible-option-title"><strong>data_volume_templates</strong></p>
      <a class="ansibleOptionLink" href="#parameter-data_volume_templates" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">list</span>
        / <span class="ansible-option-elements">elements=dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the <code class='docutils literal notranslate'>DataVolume</code> templates of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>See <a href='https://kubevirt.io/api-reference/main/definitions.html#_v1_datavolumetemplatespec'>https://kubevirt.io/api-reference/main/definitions.html#_v1_datavolumetemplatespec</a></p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-delete_options"></div>
      <p class="ansible-option-title"><strong>delete_options</strong></p>
      <a class="ansibleOptionLink" href="#parameter-delete_options" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Configure behavior when deleting an object.</p>
      <p>Only used when <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=absent</span></span></a></code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-delete_options/preconditions"></div>
      <p class="ansible-option-title"><strong>preconditions</strong></p>
      <a class="ansibleOptionLink" href="#parameter-delete_options/preconditions" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Specify condition that must be met for delete to proceed.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-delete_options/preconditions/resourceVersion"></div>
      <p class="ansible-option-title"><strong>resourceVersion</strong></p>
      <a class="ansibleOptionLink" href="#parameter-delete_options/preconditions/resourceVersion" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Specify the resource version of the target object.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-delete_options/preconditions/uid"></div>
      <p class="ansible-option-title"><strong>uid</strong></p>
      <a class="ansibleOptionLink" href="#parameter-delete_options/preconditions/uid" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Specify the <code class='docutils literal notranslate'>UID</code> of the target object.</p>
    </div></td>
  </tr>

  <tr class="row-even">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-delete_options/propagationPolicy"></div>
      <p class="ansible-option-title"><strong>propagationPolicy</strong></p>
      <a class="ansibleOptionLink" href="#parameter-delete_options/propagationPolicy" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Use to control how dependent objects are deleted.</p>
      <p>If not specified, the default policy for the object type will be used. This may vary across object types.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Foreground&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Background&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Orphan&#34;</code></p></li>
      </ul>

    </div></td>
  </tr>

  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-force"></div>
      <p class="ansible-option-title"><strong>force</strong></p>
      <a class="ansibleOptionLink" href="#parameter-force" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">boolean</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>If set to <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-force"><span class="std std-ref"><span class="pre">force=yes</span></span></a></code>, and <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code> is set, an existing object will be replaced.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-default-bold"><strong>false</strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">true</code></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-generate_name"></div>
      <p class="ansible-option-title"><strong>generate_name</strong></p>
      <a class="ansibleOptionLink" href="#parameter-generate_name" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the basis of the <code class='docutils literal notranslate'>VirtualMachine</code> name and random characters will be added automatically on the cluster to generate a unique name.</p>
      <p>Only used when <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code>.</p>
      <p>Mutually exclusive with <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-name"><span class="std std-ref"><span class="pre">name</span></span></a></strong></code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-host"></div>
      <p class="ansible-option-title"><strong>host</strong></p>
      <a class="ansibleOptionLink" href="#parameter-host" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Provide a URL for accessing the API.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_HOST</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-impersonate_groups"></div>
      <p class="ansible-option-title"><strong>impersonate_groups</strong></p>
      <a class="ansibleOptionLink" href="#parameter-impersonate_groups" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">list</span>
        / <span class="ansible-option-elements">elements=string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Group(s) to impersonate for the operation.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_IMPERSONATE_GROUPS</code> environment variable, e.g. <code class='docutils literal notranslate'>Group1,Group2</code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-impersonate_user"></div>
      <p class="ansible-option-title"><strong>impersonate_user</strong></p>
      <a class="ansibleOptionLink" href="#parameter-impersonate_user" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Username to impersonate for the operation.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_IMPERSONATE_USER</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-instancetype"></div>
      <p class="ansible-option-title"><strong>instancetype</strong></p>
      <a class="ansibleOptionLink" href="#parameter-instancetype" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the <code class='docutils literal notranslate'>Instancetype</code> matcher of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>Only used when <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-kubeconfig"></div>
      <p class="ansible-option-title"><strong>kubeconfig</strong></p>
      <a class="ansibleOptionLink" href="#parameter-kubeconfig" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">any</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>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 <em>~/.kube/config</em>.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_KUBECONFIG</code> environment variable.</p>
      <p>Multiple Kubernetes config file can be provided using separator <code class='docutils literal notranslate'>;</code> for Windows platform or <code class='docutils literal notranslate'>:</code> for others platforms.</p>
      <p>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-labels"></div>
      <p class="ansible-option-title"><strong>labels</strong></p>
      <a class="ansibleOptionLink" href="#parameter-labels" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify labels to set on the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-name"></div>
      <p class="ansible-option-title"><strong>name</strong></p>
      <a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the name of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>This option is ignored when <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code> is not set.</p>
      <p>Mutually exclusive with <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-generate_name"><span class="std std-ref"><span class="pre">generate_name</span></span></a></strong></code>.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-namespace"></div>
      <p class="ansible-option-title"><strong>namespace</strong></p>
      <a class="ansibleOptionLink" href="#parameter-namespace" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
        / <span class="ansible-option-required">required</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the namespace of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-no_proxy"></div>
      <p class="ansible-option-title"><strong>no_proxy</strong></p>
      <a class="ansibleOptionLink" href="#parameter-no_proxy" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_NO_PROXY</code> environment variable.</p>
      <p>Please note that this module does not pick up typical proxy settings from the environment (e.g. <code class="xref std std-envvar literal notranslate">NO_PROXY</code>).</p>
      <p>This feature requires <code class='docutils literal notranslate'>kubernetes&gt;=19.15.0</code>. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</p>
      <p>Example value is <code class='docutils literal notranslate'>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</code>.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-password"></div>
      <p class="ansible-option-title"><strong>password</strong></p>
      <a class="ansibleOptionLink" href="#parameter-password" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Provide a password for authenticating with the API.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_PASSWORD</code> environment variable.</p>
      <p>Please read the description of the <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-username"><span class="std std-ref"><span class="pre">username</span></span></a></strong></code> option for a discussion of when this option is applicable.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-persist_config"></div>
      <p class="ansible-option-title"><strong>persist_config</strong></p>
      <a class="ansibleOptionLink" href="#parameter-persist_config" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">boolean</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Whether or not to save the kube config refresh tokens.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_PERSIST_CONFIG</code> environment variable.</p>
      <p>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.</p>
      <p>Disabled by default.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">false</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">true</code></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-preference"></div>
      <p class="ansible-option-title"><strong>preference</strong></p>
      <a class="ansibleOptionLink" href="#parameter-preference" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the <code class='docutils literal notranslate'>Preference</code> matcher of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>Only used when <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-proxy"></div>
      <p class="ansible-option-title"><strong>proxy</strong></p>
      <a class="ansibleOptionLink" href="#parameter-proxy" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>The URL of an HTTP proxy to use for the connection.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_PROXY</code> environment variable.</p>
      <p>Please note that this module does not pick up typical proxy settings from the environment (e.g. <code class="xref std std-envvar literal notranslate">HTTP_PROXY</code>).</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-proxy_headers"></div>
      <p class="ansible-option-title"><strong>proxy_headers</strong></p>
      <a class="ansibleOptionLink" href="#parameter-proxy_headers" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>The Header used for the HTTP proxy.</p>
      <p>Documentation can be found here <a href='https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers'>https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers</a>.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-proxy_headers/basic_auth"></div>
      <p class="ansible-option-title"><strong>basic_auth</strong></p>
      <a class="ansibleOptionLink" href="#parameter-proxy_headers/basic_auth" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Colon-separated username:password for basic authentication header.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_PROXY_HEADERS_BASIC_AUTH</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-proxy_headers/proxy_basic_auth"></div>
      <p class="ansible-option-title"><strong>proxy_basic_auth</strong></p>
      <a class="ansibleOptionLink" href="#parameter-proxy_headers/proxy_basic_auth" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Colon-separated username:password for proxy basic authentication header.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-proxy_headers/user_agent"></div>
      <p class="ansible-option-title"><strong>user_agent</strong></p>
      <a class="ansibleOptionLink" href="#parameter-proxy_headers/user_agent" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>String representing the user-agent you want, such as foo/1.0.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_PROXY_HEADERS_USER_AGENT</code> environment variable.</p>
    </div></td>
  </tr>

  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-run_strategy"></div>
      <p class="ansible-option-title"><strong>run_strategy</strong></p>
      <a class="ansibleOptionLink" href="#parameter-run_strategy" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
      <p><em class="ansible-option-versionadded">added in kubevirt.core 2.0.0</em></p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the <code class='docutils literal notranslate'>RunStrategy</code> of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>Mutually exclusive with <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-running"><span class="std std-ref"><span class="pre">running</span></span></a></strong></code>.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Always&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Halted&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Manual&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;RerunOnFailure&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;Once&#34;</code></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-running"></div>
      <p class="ansible-option-title"><strong>running</strong></p>
      <a class="ansibleOptionLink" href="#parameter-running" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">boolean</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify whether the <code class='docutils literal notranslate'>VirtualMachine</code> should be running or not.</p>
      <p>Mutually exclusive with <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-run_strategy"><span class="std std-ref"><span class="pre">run_strategy</span></span></a></strong></code>.</p>
      <p>Defaults to <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-running"><span class="std std-ref"><span class="pre">running=yes</span></span></a></code> when <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-running"><span class="std std-ref"><span class="pre">running</span></span></a></strong></code> and <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-run_strategy"><span class="std std-ref"><span class="pre">run_strategy</span></span></a></strong></code> are not set.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">false</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">true</code></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-spec"></div>
      <p class="ansible-option-title"><strong>spec</strong></p>
      <a class="ansibleOptionLink" href="#parameter-spec" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">dictionary</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Specify the template spec of the <code class='docutils literal notranslate'>VirtualMachine</code>.</p>
      <p>See <a href='https://kubevirt.io/api-reference/main/definitions.html#_v1_virtualmachineinstancespec'>https://kubevirt.io/api-reference/main/definitions.html#_v1_virtualmachineinstancespec</a></p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-state"></div>
      <p class="ansible-option-title"><strong>state</strong></p>
      <a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Determines if an object should be created, patched, or deleted.</p>
      <p>When set to <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code>, an object will be created, if it does not already exist.</p>
      <p>If set to <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=absent</span></span></a></code>, an existing object will be deleted.</p>
      <p>If set to <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-state"><span class="std std-ref"><span class="pre">state=present</span></span></a></code>, an existing object will be patched, if its attributes differ from those specified.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">&#34;absent&#34;</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-default-bold"><strong>&#34;present&#34;</strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-username"></div>
      <p class="ansible-option-title"><strong>username</strong></p>
      <a class="ansibleOptionLink" href="#parameter-username" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Provide a username for authenticating with the API.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_USERNAME</code> environment variable.</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-validate_certs"></div>
      <div class="ansibleOptionAnchor" id="parameter-verify_ssl"></div>
      <p class="ansible-option-title"><strong>validate_certs</strong></p>
      <a class="ansibleOptionLink" href="#parameter-validate_certs" title="Permalink to this option"></a>
      <p class="ansible-option-type-line"><span class="ansible-option-aliases">aliases: verify_ssl</span></p>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">boolean</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Whether or not to verify the API server&#x27;s SSL certificates.</p>
      <p>Can also be specified via <code class="xref std std-envvar literal notranslate">K8S_AUTH_VERIFY_SSL</code> environment variable.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">false</code></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">true</code></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-wait"></div>
      <p class="ansible-option-title"><strong>wait</strong></p>
      <a class="ansibleOptionLink" href="#parameter-wait" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">boolean</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Whether to wait for the <code class='docutils literal notranslate'>VirtualMachine</code> to end up in the ready state.</p>
      <p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
      <ul class="simple">
        <li><p><code class="ansible-value literal notranslate ansible-option-default-bold"><strong>false</strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
        <li><p><code class="ansible-value literal notranslate ansible-option-choices-entry">true</code></p></li>
      </ul>

    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-wait_sleep"></div>
      <p class="ansible-option-title"><strong>wait_sleep</strong></p>
      <a class="ansibleOptionLink" href="#parameter-wait_sleep" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">integer</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>Number of seconds to sleep between checks.</p>
      <p>Ignored if <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-wait"><span class="std std-ref"><span class="pre">wait</span></span></a></strong></code> is not set.</p>
      <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-value literal notranslate ansible-option-default">5</code></p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="parameter-wait_timeout"></div>
      <p class="ansible-option-title"><strong>wait_timeout</strong></p>
      <a class="ansibleOptionLink" href="#parameter-wait_timeout" title="Permalink to this option"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">integer</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>How long in seconds to wait for the resource to end up in the ready state.</p>
      <p>Ignored if <code class="ansible-option literal notranslate"><strong><a class="reference internal" href="#parameter-wait"><span class="std std-ref"><span class="pre">wait</span></span></a></strong></code> is not set.</p>
      <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-value literal notranslate ansible-option-default">120</code></p>
    </div></td>
  </tr>
  </tbody>
  </table>



.. Attributes


.. Notes

Notes
-----

.. note::
   - To avoid SSL certificate validation errors when \ :ansopt:`kubevirt.core.kubevirt\_vm#module:validate\_certs=yes`\ , the full certificate chain for the API server must be provided via \ :ansopt:`kubevirt.core.kubevirt\_vm#module:ca\_cert`\  or in the \ :ansopt:`kubevirt.core.kubevirt\_vm#module:kubeconfig`\  file.

.. Seealso


.. Examples

Examples
--------

.. code-block:: yaml+jinja

    
    - name: Create a VirtualMachine
      kubevirt.core.kubevirt_vm:
        state: present
        name: testvm
        namespace: default
        labels:
          app: test
        instancetype:
          name: u1.medium
        preference:
          name: fedora
        spec:
          domain:
            devices:
              interfaces:
                - name: default
                  masquerade: {}
                - name: bridge-network
                  bridge: {}
          networks:
            - name: default
              pod: {}
            - name: bridge-network
              multus:
                networkName: kindexgw
          volumes:
            - containerDisk:
                image: quay.io/containerdisks/fedora:latest
              name: containerdisk
            - cloudInitNoCloud:
                userData: |-
                  #cloud-config
                  # The default username is: fedora
                  ssh_authorized_keys:
                    - ssh-ed25519 AAAA...
              name: cloudinit

    - name: Create a VirtualMachine with a DataVolume template
      kubevirt.core.kubevirt_vm:
        state: present
        name: testvm-with-dv
        namespace: default
        labels:
          app: test
        instancetype:
          name: u1.medium
        preference:
          name: fedora
        data_volume_templates:
          - metadata:
              name: testdv
            spec:
              source:
                registry:
                  url: docker://quay.io/containerdisks/fedora:latest
              storage:
                accessModes:
                  - ReadWriteOnce
                resources:
                  requests:
                    storage: 5Gi
        spec:
          domain:
            devices: {}
          volumes:
            - dataVolume:
                name: testdv
              name: datavolume
            - cloudInitNoCloud:
                userData: |-
                  #cloud-config
                  # The default username is: fedora
                  ssh_authorized_keys:
                    - ssh-ed25519 AAAA...
              name: cloudinit
        wait: true

    - name: Delete a VirtualMachine
      kubevirt.core.kubevirt_vm:
        name: testvm
        namespace: default
        state: absent




.. Facts


.. Return values

Return Values
-------------
Common return values are documented :ref:`here <common_return_values>`, the following are the fields unique to this module:

.. raw:: html

  <table class="colwidths-auto ansible-option-table docutils align-default" style="width: 100%">
  <thead>
  <tr class="row-odd">
    <th class="head"><p>Key</p></th>
    <th class="head"><p>Description</p></th>
  </tr>
  </thead>
  <tbody>
  <tr class="row-even">
    <td><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="return-result"></div>
      <p class="ansible-option-title"><strong>result</strong></p>
      <a class="ansibleOptionLink" href="#return-result" title="Permalink to this return value"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">complex</span>
      </p>
    </div></td>
    <td><div class="ansible-option-cell">
      <p>The created object. Will be empty in the case of a deletion.</p>
      <p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> success</p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="return-result/changed"></div>
      <p class="ansible-option-title"><strong>changed</strong></p>
      <a class="ansibleOptionLink" href="#return-result/changed" title="Permalink to this return value"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">boolean</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Whether the <code class='docutils literal notranslate'>VirtualMachine</code> was changed or not.</p>
      <p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> success</p>
      <p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-value literal notranslate ansible-option-sample">true</code></p>
    </div></td>
  </tr>
  <tr class="row-even">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="return-result/duration"></div>
      <p class="ansible-option-title"><strong>duration</strong></p>
      <a class="ansibleOptionLink" href="#return-result/duration" title="Permalink to this return value"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">integer</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Elapsed time of the task in seconds.</p>
      <p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> When <code class="ansible-option-value literal notranslate"><a class="reference internal" href="#parameter-wait"><span class="std std-ref"><span class="pre">wait=true</span></span></a></code>.</p>
      <p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-value literal notranslate ansible-option-sample">48</code></p>
    </div></td>
  </tr>
  <tr class="row-odd">
    <td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
      <div class="ansibleOptionAnchor" id="return-result/method"></div>
      <p class="ansible-option-title"><strong>method</strong></p>
      <a class="ansibleOptionLink" href="#return-result/method" title="Permalink to this return value"></a>
      <p class="ansible-option-type-line">
        <span class="ansible-option-type">string</span>
      </p>
    </div></td>
    <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell">
      <p>Method executed on the Kubernetes API.</p>
      <p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> success</p>
    </div></td>
  </tr>

  </tbody>
  </table>



..  Status (Presently only deprecated)


.. Authors

Authors
~~~~~~~

- KubeVirt.io Project 



.. Extra links


.. Parsing errors

