oVirt v4 provider for Vagrant
Ruby
Latest commit 08327c5 Feb 18, 2017 @myoung34 committed on GitHub Merge pull request #68 from myoung34/gh58
Add support for host pinning and placement host

README.md

Vagrant oVirt v4 Provider

This is a Vagrant 1.1+ plugin that adds an oVirt v4 and allowing Vagrant to control and provision machines in oVirt.

Installation

$ vagrant plugin install vagrant-ovirt4
$ vagrant up --provider=ovirt4

Usage

Prerequisites

Configuration

  1. ovirt-guest-agent
  2. cloud-init
  3. User 'vagrant'
    1. password 'vagrant'
    2. Public key from here
    3. add to group with sudo no password
  4. set !requiretty in sudoers
  5. firewall off and ssh enabled

Example creation steps

  1. Create a base template
    1. Centos Example
      1. Spin up a virtual machine using the Centos 7 Generic Cloud Image from the ovirt Glance provider
      2. Once it is up and running, run the example script from inside the VM
      3. Power down the virtual machine
      4. Remove all Network Interfaces from the VM (so that the template does not have it)
      5. Right click the virtual machine and click 'Make Template'

Supported Commands (tested)

  1. vagrant up
  2. vagrant destroy
  3. vagrant ssh [-c '#command']
  4. vagrant ssh-config
  5. vagrant halt
  6. vagrant reload
  7. vagrant status
  8. vagrant suspend
  9. vagrant resume
  10. vagrant snapshot list
  11. vagrant snapshot delete [id]
  12. vagrant snapshot save [description]

Configuration example

Vagrant.configure("2") do |config|
  config.vm.box = 'ovirt4'
  config.vm.hostname = "foo" 
  config.vm.box_url = 'https://github.com/myoung34/vagrant-ovirt4/blob/master/example_box/dummy.box?raw=true'

  config.vm.network :private_network,
    :ip => '192.168.56.100', :nictype => 'virtio', :netmask => '255.255.255.0', #normal network configuration
    :ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125' # oVirt specific information, overwrites previous on oVirt provider

  config.vm.provider :ovirt4 do |ovirt|
    ovirt.url = 'https://server/ovirt-engine/api'
    ovirt.username = "admin@internal"
    ovirt.password = "password"
    ovirt.insecure = true
    ovirt.debug = true
    ovirt.cluster = 'Default'
    ovirt.template = 'Vagrant-Centos7-test'
    ovirt.console = 'vnc'
    ovirt.memory_size = '1 GiB' #see https://github.com/dominikh/filesize for usage
    ovirt.memory_guaranteed = '256 MB' #see https://github.com/dominikh/filesize for usage
    ovirt.cpu_cores = 2
    ovirt.cpu_sockets = 2
    ovirt.cpu_threads = 2
    ovirt.cloud_init =<<EOF
write_files:
  - content: |
      Hello, world!
    path: /tmp/greeting.txt
    permissions: '0644'
EOF

  end
end

Configuration options

  1. Vagrant specific
    1. config.vm.hostname => Sets the hostname of the VM a. Is the 'name' in the Virtual Machine tab of the UI a. Is the 'hostname' of the VM configured by cloud-init
    2. config.vm.network => Sets the network information of the VM. a. Note: :ip => is ignored, but :ovirt__ip is used and merged with :ip
  2. Provider specific
    1. config.vm.network => Sets the network information of the VM. a. Note: Only :private_network is currently supported. a. If :ovirt__ip is provided, then the network type is assumed 'STATIC' and gateway is also used.
    2. url => The URL for the API. Required. String. No default value.
    3. username => The username for the API. Required. String. No default value.
    4. password => The password for the API. Required. String. No default value.
    5. insecure => Allow connecting to SSL sites without certificates. Optional. Bool. Default is false
    6. debug => Turn on additional log statements. Optional. Bool. Default is false.
    7. datacenter => The name of the ovirt datacenter to create within. Required. String. No Default value. a. Note: (TODO) Unknown usage
    8. template => The name of the template to use for creation. Required. String. No Default value.
    9. cluster => The name of the ovirt cluster to create within. Required. String. No Default value.
    10. console => The type of remote viewing protocol to use. Required. String. No Default value. a. Note: (TODO) Enforce this to be Spice, VNC, and RDP
    11. memory_size => The physical size of the memory for the VM (in MB). Defaults to 256
    12. memory_guaranteed => The guaranteed size of the memory for the VM (in MB). Note: cannot be larger than memory_size. Defaults to memory_size
    13. cpu_cores => The number of CPU cores. Defaults to 1
    14. cpu_sockets => The number of CPU cores. Defaults to 1
    15. cpu_threads => The number of CPU threads. Defaults to 1
    16. cloud_init => The cloud-init data to pass. Must be properly formatted as yaml. Docs here
    17. affinity => The affinity to use. See this for possible uses. Optional. Invalid will cause a RuntimeError
    18. placement_host => The host to start the VM on. Optional.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request