GithubHelp home page GithubHelp logo

ansible-vsphere's Introduction

ansible-vsphere

Ansible module to automate the vsphere api.

This module uses the official VMWare python library https://github.com/vmware/pyvmomi. Current supported features:

  1. Power on, Guest Shutdown, Power off VMs
  2. Create, Delete, Clone VMs
  3. Upgrade VMWare Tools
  4. Create, Delete, Revert VM Snapshots
  5. Using the Guest Operations Manager

The module takes a special spec object that will be converted to the correct vsphere object during processing of the task. The spec object has two top level parameters: type: The type of spec ( such as VirtualMachineCloneSpec ) In some cases this could be the name of a function that will be called. value: A representation of the values that fill out the spec object. In the case of the spec being used to specify a function being called, the values should be the parameters that get passed to the function.

In order to fill spec objects with other spec objects, the values will be put through a recursive update, that will convert any key that is an attribute of the vim module of pyVmomi. The update process can even substitute Managed Object References through the special syntax. { "ManagedObjectReference" : { "type": "MOR TYPE", "name" : "MOR NAME" } }

For example below is how to clone a VM. The type VirtualMachineCloneSpec corresponds directly to the definition at http://pubs.vmware.com/vsphere-55/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.vm.CloneSpec.html

- name: Clone VM
  local_action:
    module: vsphere
    host: "{{ vcenter_host }}"
    login: "{{ vcenter_login }}"
    password: "{{ vcenter_password }}"
    timeout: 60
    guest:
      name: "{{ deleteme }}"
      state: present
      folder: "{{ folder }}"
      clone_from: base-tmpl
    spec:
      type: VirtualMachineCloneSpec
      value:
        config:
          VirtualMachineConfigSpec:
            name: "{{ deleteme }}"
            memoryMB: 2048
            numCPUs: 1
            deviceChange: []
        location:
          VirtualMachineRelocateSpec:
            pool:
              ManagedObjectReference:
                type: ResourcePool
                name: Resources
        powerOn: False
        template: False

ansible-vsphere's People

Contributors

gcoffey avatar ozans avatar tkinz27 avatar

Watchers

 avatar  avatar  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.