Documentation

rhevm - RHEV/oVirt automation

New in version 2.2.

Synopsis

  • This module only supports oVirt/RHEV version 3. A newer module ovirt_vm supports oVirt/RHV version 4.
  • Allows you to create/remove/update or powermanage virtual machines on a RHEV/oVirt platform.

Requirements

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

  • ovirtsdk

Parameters

Parameter Choices/Defaults Comments
boot_order Default:
[u'network', u'hd']
This option uses complex arguments and is a list of items that specify the bootorder.
cd_drive
The CD you wish to have mounted on the VM when state = 'CD'.
cluster
The rhev/ovirt cluster in which you want you VM to start.
cpu_share Default:
0
This parameter is used to configure the cpu share.
datacenter Default:
Default
The rhev/ovirt datacenter in which you want you VM to start.
del_prot
bool
    Choices:
  • no
  • yes ←
This option sets the delete protection checkbox.
disks
This option uses complex arguments and is a list of disks with the options name, size and domain.
ifaces
This option uses complex arguments and is a list of interfaces with the options name and vlan.

aliases: nics, interfaces
image
The template to use for the VM.
insecure_api
bool
    Choices:
  • no ←
  • yes
A boolean switch to make a secure or insecure connection to the server.
mempol Default:
1
The minimum amount of memory you wish to reserve for this system.
name
The name of the VM.
osver Default:
rhel_6x64
The operationsystem option in RHEV/oVirt.
port Default:
443
The port on which the API is reacheable.
server Default:
127.0.0.1
The name/ip of your RHEV-m/oVirt instance.
state
    Choices:
  • ping
  • present ←
  • absent
  • up
  • down
  • restarted
  • cd
  • info
This serves to create/remove/update or powermanage your VM.
timeout
The timeout you wish to define for power actions.
When state = 'up'
When state = 'down'
When state = 'restarted'
type
    Choices:
  • server ←
  • desktop
  • host
To define if the VM is a server or desktop.
user Default:
The user to authenticate with.
vm_ha
bool
    Choices:
  • no
  • yes ←
To make your VM High Available.
vmcpu Default:
2
The number of CPUs you want in your VM.
vmhost
The host you wish your VM to run on.
vmmem Default:
1
The amount of memory you want your VM to use (in GB).

Examples

# basic get info from VM
  - rhevm:
      name: "demo"
      user: "{{ rhev.admin.name }}"
      password: "{{ rhev.admin.pass }}"
      server: "rhevm01"
      state: "info"

# basic create example from image
  - rhevm:
      name: "demo"
      user: "{{ rhev.admin.name }}"
      password: "{{ rhev.admin.pass }}"
      server: "rhevm01"
      state: "present"
      image: "centos7_x64"
      cluster: "centos"

# power management
  - rhevm:
      name: "uptime_server"
      user: "{{ rhev.admin.name }}"
      password: "{{ rhev.admin.pass }}"
      server: "rhevm01"
      cluster: "RH"
      state: "down"
      image: "centos7_x64"

# multi disk, multi nic create example
  - rhevm:
      name: "server007"
      user: "{{ rhev.admin.name }}"
      password: "{{ rhev.admin.pass }}"
      server: "rhevm01"
      cluster: "RH"
      state: "present"
      type: "server"
      vmcpu: 4
      vmmem: 2
      ifaces:
        - name: "eth0"
          vlan: "vlan2202"
        - name: "eth1"
          vlan: "vlan36"
        - name: "eth2"
          vlan: "vlan38"
        - name: "eth3"
          vlan: "vlan2202"
      disks:
        - name: "root"
          size: 10
          domain: "ssd-san"
        - name: "swap"
          size: 10
          domain: "15kiscsi-san"
        - name: "opt"
          size: 10
          domain: "15kiscsi-san"
        - name: "var"
          size: 10
          domain: "10kiscsi-san"
        - name: "home"
          size: 10
          domain: "sata-san"
      boot_order:
        - "network"
        - "hd"

# add a CD to the disk cd_drive
  - rhevm:
      name: 'server007'
      user: "{{ rhev.admin.name }}"
      password: "{{ rhev.admin.pass }}"
      state: 'cd'
      cd_drive: 'rhev-tools-setup.iso'

# new host deployment + host network configuration
  - rhevm:
      name: "ovirt_node007"
      password: "{{ rhevm.admin.pass }}"
      type: "host"
      state: present
      cluster: "rhevm01"
      ifaces:
        - name: em1
        - name: em2
        - name: p3p1
          ip: '172.31.224.200'
          netmask: '255.255.254.0'
        - name: p3p2
          ip: '172.31.225.200'
          netmask: '255.255.254.0'
        - name: bond0
          bond:
            - em1
            - em2
          network: 'rhevm'
          ip: '172.31.222.200'
          netmask: '255.255.255.0'
          management: True
        - name: bond0.36
          network: 'vlan36'
          ip: '10.2.36.200'
          netmask: '255.255.254.0'
          gateway: '10.2.36.254'
        - name: bond0.2202
          network: 'vlan2202'
        - name: bond0.38
          network: 'vlan38'

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
vm
dict
always
Returns all of the VMs variables and execution.

Sample:
{ "boot_order": [ "hd", "network" ], "changed": true, "changes": [ "Delete Protection" ], "cluster": "C1", "cpu_share": "0", "created": false, "datacenter": "Default", "del_prot": true, "disks": [ { "domain": "ssd-san", "name": "OS", "size": 40 } ], "eth0": "00:00:5E:00:53:00", "eth1": "00:00:5E:00:53:01", "eth2": "00:00:5E:00:53:02", "exists": true, "failed": false, "ifaces": [ { "name": "eth0", "vlan": "Management" }, { "name": "eth1", "vlan": "Internal" }, { "name": "eth2", "vlan": "External" } ], "image": false, "mempol": "0", "msg": [ "VM exists", "cpu_share was already set to 0", "VM high availability was already set to True", "The boot order has already been set", "VM delete protection has been set to True", "Disk web2_Disk0_OS already exists", "The VM starting host was already set to host416" ], "name": "web2", "type": "server", "uuid": "4ba5a1be-e60b-4368-9533-920f156c817b", "vm_ha": true, "vmcpu": "4", "vmhost": "host416", "vmmem": "16" }


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Maintenance

This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.

For a list of other modules that are also maintained by the Ansible Community, see here.

Author

  • Timothy Vandenbrande (@TimothyVandenbrande)

Hint

If you notice any issues in this documentation you can edit this document to improve it.