Giter Site home page Giter Site logo

ansible-vmware's Introduction

ansible-vmware

Working with Ansible and VMware ESXi/vCenter

Prerequisites

  • VMware ESXi
  • vCenter
  • Ansible 2.4.4 or greater
  • one VM template in VMware ESXi/vCenter with an OS installed to use as a source

That last one for me is basically the following:

  1. Create a VM in ESXi
  2. Install an OS on it
  3. Convert it to a template

Caveats

My current VMware ESXi environment is statically managed - No DHCP, no LDAP, not much use of DNS - so that means that dynamic inventory doesn't apply and things are managed by a hosts file for the most part.

I also primarily only use Linux, and RedHat at that. This project doesn't have much Windows+Ansible at the moment, though it's on the list to get in at some point.

Usage

Use pip and pipenv.

sudo easy_install pip
pip install pipenv
pipenv install
pipenv shell

ansible all -i inventory --list-hosts
ansible-playbook -i inventory/esxi playbooks/esxi/update_template.yml
ansible-playbook -i inventory/prod_db playbooks/esxi/refresh_vm.yml
ansible-playbook -i inventory/prod_db playbooks/esxi/create_snapshot.yml
ansible-playbook -i inventory/prod_db playbooks/prod_db/clean.yml
ansible-playbook -i inventory/prod_db playbooks/prod_db/snapshot.yml

If you don't want to use pipenv, you need to have

  • ansible
  • passlib
  • pyvmomi

in your PYTHONPATH.

Set the variable values in roles/esxi/vars/main.yml for your VMware ESXi/vCenter environment.

Set the variable values in inventory/esxi/group_vars/all.yml for your VMware ESXi/vCenter environment.

Set the variable values for each host in the esxi inventory.

Set the variable values for each host in the prod_db inventory.

Set the proper configurations in roles/common/files.

Notes

The vmware_guest module in Ansible has more functionality than what is demonstrated here.

There are potential opportunities for naming convention collisions: My VMware environment is tiny, so I don't use the approach of dynamic inventory at all, though it should be investigated. That means you should pay attention to naming conventions, or change the plays/tasks to use the returned ids from the vmware_guest module.

Performance could probably be improved with more register and when combinations in the roles. That is an exercise for the user.

ansible-vmware's People

Contributors

nickrnet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

infernofeniks

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.