Giter Club home page Giter Club logo

ansible-kubevirt-modules's Introduction

Ansible KubeVirt Modules

Ansible modules for KubeVirt management.

Contents

  • lib: Ansible modules files for KubeVirt management
    • kubevirt_raw: Allow to manage KubeVirt resources, VirtualMachineInstance, VirtualMachine, VirtualMachineInstanceReplicaSet and VirtualMachineInstancePresets.
    • kubevirt_facts: Gather facts about a given resource.
    • kubevirt_vm_status: Set an VirtualMachine to either running or stopped.
    • kubevirt_scale_vmirs: Scale up or down a VirtualMachineInstanceReplilcaSet.
  • tests: Ansible playbook examples and unit tests

Requirements

Installation and usage

  1. Install the modules:

    1. From GitHub:

      $ git clone https://github.com/kubevirt/ansible-kubevirt-modules
    2. From Ansible Galaxy

      $ ansible-galaxy install -p <roles_path> kubevirt.kubevirt-modules
  2. Setting up the environment

$ export ANSIBLE_MODULE_UTILS=<module_path>/lib/ansible/module_utils
$ export ANSIBLE_LIBRARY=<module_path>/lib/ansible/modules

NOTE: These settings can instead be added to ansible.cfg as done in test/ansible.cfg

  1. A working Kubernetes configuration is also required. It can also be created by issuing oc login if using KubeVirt with OpenShift.

  2. Install KubeVirt Python SDK

  3. Install Kubernetes Python client

  4. Once installed, add it to a playbook:

---
- hosts: localhost
  roles:
    - role: ansible-kubevirt-modules
      install_python_requirements: no
    - role: hello-underworld

Because the role is referenced, the hello-underworld role is able to make use of the kubevirt modules.

Playbook examples

Local testing

  1. Run the tests as follows:
$ export ANSIBLE_CONFIG=tests/ansible.cfg
$ ansible-playbook tests/playbooks/<playbook>
  1. The playbook examples, include cloud-init configuration, for being able to access the VMIs created.

    1. For using SSH do as follows:

      $ kubectl get all
      NAME                             READY     STATUS    RESTARTS   AGE
      po/virt-launcher-bbecker-jw5kk   1/1       Running   0          22m
      
      $ kubectl expose pod virt-launcher-bbecker-jw5kk --port=27017 --target-port=22 --name=vmservice
      $ kubectl get svc vmservice
      NAME        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)     AGE
      vmservice   ClusterIP   172.30.133.9   <none>        27017/TCP   19m
      
      $ ssh -i tests/kubevirt_rsa -p 27017 [email protected]

      NOTE: It might take a while for the VM to completely come up before SSH can be used.

    2. For using virtctl:

      $ virtctl console <vmi_name>

      Or

      $ virtctl vnc <vmi_name>

      NOTE: Use username kubevirt and password kubevirt.

Facts

  • Once one of the previous resources has been created, the facts module can be tested as well as follows:
$ ansible-playbook tests/playbooks/kubevirt_vm_facts.yml

The above command, will gather the information for the VM stated in the playbook and print out a JSON document based on KubeVirt VM spec.

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.