Git Product home page Git Product logo

ansible-libvirt's Introduction

Role Name

A role to set up Libvirt with KVM as well as create KVM machines. Forked from https://github.com/hicknhack-software/ansible-libvirt

One Line Install

sudo ansible-galaxy install kireledan.libvirt
echo -ne "- hosts: localhost\n  remote_user: root\n  roles:\n    - kireledan.libvirt\n  vars:\n    state: install" > inst.yml
ansible-playbook inst.yml

Role Variables

image_download_path: "Path to download images"

libvirt_images_path: "Path of converted images (Be careful with changing this)"

libvirt_domain:
  # basic arguments
  groups: [] # names of Ansible nodes/groups used to provision the domain
  name: # name/uuid of the domain (empty means new uuid)
  title: '' # title of the vm
  description: '' # description of the vm
  apt_mirror: ''
  # note: if you do not provide a domain_id each run will create a new vm!

  # default VM configuration
  vm:
    memory: "512MiB" # RAM memory available to the VM
    vcpu: 1 # number of cores designated to the VM
    vcpu_placement: 'static' # options 'auto', 'static', defaults to 'numatune'
    vcpu_cpuset: [] # list of host CPU numbers the VM can run on
    networks: ['default'] # libvirts id of networks this VM is part of
    disk_size: "12G" # use this to change first disk size
    features: ['acpi', 'apic', 'pae'] # vm features available

  image_url: 'url to use'
  pubkey: 'ssh key to add to instance'

libvirt_cloud_config_default_user:
  name: 'ubuntu'
  gecos: 'Ubuntu'

Example Playbook

To set up the host.

    - hosts: localhost
  	  remote_user: root
  	  roles:
  	    - kireledan.libvirt
  	  vars:
  	    state: install

To Create a VM

- hosts: localhost
  remote_user: root
  roles:
    - kireledan.libvirt
  vars:
    state: create
    libvirt_domain:
      groups: ['cluster'] 
      name: 'Testing'
      title: 'Machine1' 
      description: 'test'
      image_url: "https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img"
      pubkey: "your ssh-key pub"

( The playbook will print the IP address of the machine created )

To Destroy the VM

- hosts: localhost
  remote_user: root
  roles:
    - kireledan.libvirt
  vars:
    state: destroy
    to_destroy: 
      - 'Testing'

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.