Giter VIP home page Giter VIP logo

ansible-qemu-kvm's Introduction

ansible-qemu-kvm

Ansible role to provision virtual machines using the QEMU and KVM systems.

Think of it like OpenStack for poor people.

Currently, this role only creates virtual machines running the lite version of Ubuntu 18.04. Future versions may expand on this, but it is the primary server operating system that I use.

Usage

Add this role to the roles directory in your ansible project.

Then, include the role using a top level playbook:

- name: KVM hosts 
  hosts: kvm-hosts
  become: true 
  roles: 
    - ansible-qemu-kvm

Variables

This role requires these variables to exist in inventory:

1. Users

users: 
- name: ongo
  full_name: Ongo Gablogian 
  passwd: $6$rounds=2048$aaaaaaaa
  pub_key: ssh-rsa AAAAB3N [email protected]

This is a list of users that should be added to the server during provisioning.

The passwd and pub_key parameters take your hashed password and your SSH public key so that you are able to access the server after provisioning.

To generate a new password hash, use mkpasswd -m sha-512 -R 2048 (Included in the whois package).

2. VMs

virtual_machines: 
- name: u18-svr-001
  cpu: 1
  mem: 1024
  disk: 10G
  bridge: br10 

This is a list of virtual machines that should be built.

Bridge: this is the name of the bridge device that references the vlan the server will be connected to. This must already exist on the KVM host.

The virtual machine can also be built with a static IP address:

- name: u18-svr-002
  cpu: 1
  mem: 512 
  disk: 5G
  bridge: br10 
  net: 
    ip: 10.11.12.13/24
    gateway: 10.11.12.1 
    domain: gablogianartcollection.org
    dns: 
      - 1.1.1.1
      - 9.9.9.9

This variable takes exactly one IP address, domain, and gateway; and two or more DNS servers.

Default Values

If no value is supplied, the default settings will be used:

  • CPU: 1 core
  • Memory: 512 MB
  • Disk: 5GB .qcow image
  • Bridge: Default libvirt NAT network
  • Network: DHCP

How it works

This role works by downloading the Ubuntu 18.04 cloud image, then converting it to Copy-On-Write format and cloning it for each virtual machine defined.

When VMs are launched, they are given a small secondary disk image that includes a cloud-config file. This file is generated from a template that includes all the users and system parameters that are defined in inventory. There is also a network-config file that contains network metadata in Netplan-V2 format.

Before running this, ensure that networking is correctly configured on the KVM hosts.

ansible-qemu-kvm's People

Contributors

noahbailey avatar

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.