Is there an Ansible Playbook for provisioning an OS using ESX/i? - centos

Is their a way to provision an OS(Centos/Redhat) when using a licensed VMware vSphere server (with ESX/i) using ansible?

The vsphere_guest module will allow you to provision a guest VM through Ansible. If you want to do everything automatically via Ansible then you probably want to have the guest launch a kickstart to automate the install of linux onto the VM, and once that's complete then you can use Ansible to perform any customizations to the environment that you desire.

Official VMware python bindings https://github.com/vmware/pyvmomi. Ansible uses pysphere. I thought that you can develop ansible module:
Ansible modules are reusable units of magic that can be used by the
Ansible API, or by the ansible or ansible-playbook programs. The
directory ”./library”, alongside your top level playbooks, is also
automatically added as a search directory.
http://docs.ansible.com/ansible/developing_modules.html#tutorial
Or take unofficial ansible module build on pyvmomi:
- https://github.com/ViaSat/ansible-vsphere
But as I see here: https://github.com/sijis/pyvmomi-examples/blob/master/create-vm.py you need vCenter.
There are vagrant plugins but I don't think that you can do provision on ESXi without vCenter.

Related

Packer - Windows Server 2012R2 - Install PowerShell 5

I'm having trouble with installing PowerShell 5 on Windows Server 2012 R2 using Packer.
To install PowerShell 5.1, I'm using chocolatey
powershell
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
choco install PowerShell -y
I need to to do this for two packer builder:
Amazon Web Services EC2 AMI.
Hyper-V Vagrant.
With the Amazon Web Services EC2 AMI I've tried executing the above from the following locations
As part of the user_data_file script.
As an inline provision script.
I've added the windows-restart provision in the flow after the execution of the fragment.
Similarly I've tried the same with the Hyper-V Vagrant both as part of the Autounattend flow and as an inline provision.
In both cases the installation fails because the user profile is not created. At least I think that is the problem. As a reference, I've faced the exact same problem when installing sql server express.
Has anyone managed to accomplish this flow and what is your recommendation?
PowerShell package uses MSU (Windows Update file). There are a couple of considerations here:
Ensure Windows Updates Service is turned on. Chocolatey doesn't do that yet, although there is an issue filed.
MSUs must be run locally from the machine. So if you are running over WinRM, you instead need to have it set up a scheduled task to call choco install and then run it that way.
Yes, that second point is accurate. No, it is not Chocolatey's fault. That's a Microsoft design decision with MSU files. It's a real PITA.
FYI - BoxStarter handles it appropriately, and it can be used with Packer. You will find less pain if you look there.
HTH

how to install operating system on a virtual machine programatically

It may be a duplicate question but i could not find it anywhere.
Anyway, my goal to install operating system(both linux and windows) programatically on a virtual machine running on vmware hosts.
Although my search, I am quite lost about where to start.
Is there a framework or project you can suggest?
You could use templates; i.e. create a VM, install the Linux distribution of your choice and make the VM a template. Then don't create VMs but deploy the template.
Alternatively, google for the Linux distribution of your choice and something like "network installation". You'll need a DHCP server and probably a TFTP and/or web server.
Working with Templates and Clones
Creating VMware Virtual Machine Templates
Try having a look at Vagrant: http://www.vagrantup.com/. It allows you to install/uninstall a predefined VM from the command line.

Chef running from the outside

is there a way to provision a server with Chef without having Ruby installed on the server that is going to be provisioned?
Basically in the same way that Capistrano is used to provision a server?
thx
ciao robertj
You can use the Chef Omnibus Installer to install a native package for your OS including Chef Client and needed Ruby runtime packaged into one - but Ruby is always needed to be installed.
Currently Chef is not able to remotely provision a server via ssh orso.

Automated deployment using VMware powercli

We are having build environment where we did not use any tools like Cruise control , TFS or buildforge.
We are purely depend upon Msbuild and powershell. We decided to automate the deployment process.
As we are using VMWare ESXi to meet our Virtual machine needs. We decided to use VMWare powercli to automate deployment process.
After build is over , VMware powercli will revert the snapshot of VM to fresh state and we tried using Invoke-VMScript to do automated deployment.
But as our deployment has UI , this is nearly impossible as Powercli try to invoke UI in session 0 and it doesn't support UI application.
Does any body overcome this problem and installed your application successfully in Virtual machine?
I have some experience in the area. I use PowerCLI and Windows Remote to get the job done. I have a machine with VMWare snapshot where windows remoting is activated and configured and then I use PowerCLI to revert to snapshot and power the machine on and then I call Invoke-Command. Not sure if it will survive the UI thing, but worth a try. First make sure that you can execute your task from PowerShell and if yes - then windows remouting will most probably be able to do it as well. You can read how to configure Windows Remouting here:
http://amarchuk.blogspot.com/2011/10/windows-remoting-and-powershell.html

how do you build your appliances?

virtual machines hold great promise as a way to distribute hard to configure applications. i have been using jeos vmbuilder (and some bash scripts) to generate my appliances, but i'm looking for something more elegant.
in my case, i'm looking for a solution that will build a linux-based vm with configured versions of tomcat and mysql as a base. each future release would be a new war file and a sql update script. it'd be really nice if already deployed vms could self-update and test builds could be pushed to ec2.
in my brief search, i've found rpath rbuilder, turnkey linux,
vagrant up, suse studio, jeos vmbuilder, and vmware studio. rather than try all of these, i figure i'd ask what this community uses to build and distribute appliances...
I use pungi myself.