ovirt.vm-infra

oVirt Virtual Machine Infrastructure

Important Update

This role is now part of the oVirt Ansible Collection. Please use the latest version from there. This repository is read-only and will not receive active updates.

The ovirt.vm-infra role manages your virtual machine infrastructure in oVirt. It also creates an inventory of virtual machines that have an IP address if wait_for_ip is set to true and the machine's state is running. All listed virtual machines are included in the ovirt_vm inventory group. Additionally, if any tags are assigned to a virtual machine, separate inventory groups (like ovirt_tag_{tag_name}) will be created.

Example Variable Structure

vms:
  - name: myvm1
    tag: mytag1
    profile: myprofile

  - name: myvm2
    tag: mytag2
    profile: myprofile

This will create the ovirt_vm inventory group containing both myvm1 and myvm2. It will also create ovirt_tag_mytag1 for myvm1 and ovirt_tag_mytag2 for myvm2.

Note

When installing this role from Ansible Galaxy, run:

$ ansible-galaxy install ovirt.vm-infra

This command will download the role into a folder named ovirt.vm-infra. Be careful with capitalization; using OVIRT.vm-infra will create a folder named OVIRT.vm-infra.

For RPM installations, you can use any of the following names: ovirt.vm-infra, oVirt.vm-infra, or ovirt-vm-infra. This guide uses ovirt.vm-infra as the standard name.

Requirements

  • Ansible version 2.9 or higher
  • Python SDK version 4.3 or higher
  • python3-jmespath or python2-jmespath

Limitations

  • Does not support Ansible Check Mode (Dry Run).

Role Variables

Name Default Value Description
vms UNDEF List of virtual machine specifications.
affinity_groups UNDEF List of affinity group specifications.
wait_for_ip false If true, waits for the VM's IP address.
wait_for_ip_version v4 IP version to wait for (v4 or v6).
wait_for_ip_range 0.0.0.0/0 CIDR of the VM IP address to report (only for IPv4).
debug_vm_create false If true, logs tasks during VM creation.
vm_infra_create_single_timeout 180 Timeout in seconds for a VM to be created and started.
vm_infra_create_poll_interval 15 Time in seconds between checks for VM state.
vm_infra_create_all_timeout computed Total time to wait for all VMs to be created.
vm_infra_wait_for_ip_retries 5 Number of retries to check the VM's IP.
vm_infra_wait_for_ip_delay 5 Delay in seconds between IP checks.

The vms and profile variables can also contain the following attributes:

Name Default Value Description
name UNDEF Name of the virtual machine.
tag UNDEF Tag assigned to the virtual machine (admin only).
cloud_init UNDEF Values for Unix-like VM initialization.
sysprep UNDEF Values for Windows VM initialization.
profile UNDEF Hardware specifications for the VM.
state present VM status: stopped, present, or running.

Example Playbook

---
- name: oVirt infrastructure setup
  hosts: localhost
  connection: local
  gather_facts: false

  vars_files:
    - passwords.yml

  vars:
    engine_fqdn: ovirt-engine.example.com
    engine_user: admin@internal
    engine_cafile: /etc/pki/ovirt-engine/ca.pem

    httpd_vm:
      cluster: production
      domain: example.com
      template: rhel7
      memory: 2GiB
      cores: 2
      ssh_key: ssh-rsa AAA...LGx user@fqdn
      disks:
        - size: 10GiB
          name: data
          storage_domain: mynfsstorage
          interface: virtio

    vms:
      - name: apache-vm
        tag: apache
        profile: "{{ httpd_vm }}"

    affinity_groups:
      - name: db-ag
        cluster: production
        vm_enforcing: true
        vm_rule: negative
        vms:
          - postgresql-vm-0
          - postgresql-vm-1

  roles:
    - ovirt.vm-infra

License

Apache License 2.0

Informazioni sul progetto

Role to manage virtual machine infrastructure in oVirt.

Installa
ansible-galaxy install ovirt.vm-infra
Licenza
apache-2.0
Download
65.4k
Proprietario
Open Virtual Datacenter