(Yes. And Ansible. And Oracle…)
Like I’ve said before, I use Vagrant quite a lot and I basically have 2 configs that I use every time. One that uses an external ‘hosts.yml’ to define the hosts (ip, ram etc) and works really well for single instance type VM’s (be it for Oracle or something else).
Then I also had the config that was prepared for running RAC (based on the same configuration as we used for this)
It has a statically defined dns-setup (using bind), created shared disks and whatnot, and it’s been working fine for a long time.
What bugged me a little about the RAC config was:
1. All IP’s & the dns-setup were already defined, so if I wanted to set up 2 clusters I had to create another Vagrant config and hack the DNS config to use different IP’s and hostnames. Not a huge problem, but it bugged me a little.
2. All shared disks were created with the same size. If you wanted different sized disks there were ways around it though: you could set the size, run ‘vagrant up’, then shutdown the VM, change the config and alter the size of the disks, run ‘vagrant up’ again and repeat until you had the config you wanted.
Again, not a huge problem but I felt like it could be done differently.
So, last week I decided to create a new config that could provide me all the flexibility I felt was missing from the other 2 configs.
I’ve tried to build this the same way I built ansible-oracle, where I try to separate the data that defines the infrastructure from the code that actually builds it, so that the code doesn’t have to change if I want a different configuration.
So this config uses an external file (hosts.yml) to define the host(s) I want to create, along with its IP’s, disks etc.
Now, all this was done with Oracle infrastructure in mind, but is certainly not limited to that.
This new config gives me the possibility to:
- Setup any type of config I want (SI or RAC)
- Choose any IP-range I want
- Choose any hostname(s) I want
- Create local and shared disks of any size & number I want.
- It also dynamically sets up a DNS config (including vip & scan addresses in the case of RAC)
This config integrates ansible-oracle into the workflow (as a Git submodule), and that makes it possible to provision entire clusters (1 or more) with a single ‘vagrant up’.
The repo can be found at https://github.com/oravirt/vagrantfile, and the readme describes in detail how to make it work.
I also have a couple of repos prepared with different configurations if you’d want to test this. I’ve talked about the single instance ones previously.
- vagrant-vbox-rac – creates 1 or more RAC clusters
- vagrant-vbox-si-asm – creates single instance environments on ASM
- vagrant-vbox-si-fs – creates single instance environments on FS (does not use the new config yet)
The basic flow for the new config is this:
- VM(s) are built based on input from hosts.yml
- An Ansible inventory file is generated which all provisioners will use.
- The base-provisioner is run. It will configure DNS (using dnsmasq) and NTP.
- If the extra-provisioner (another Ansible playbook) is defined, that can also run.
The example repos all come with extra-provisioners defined, but it could really be any playbook you’d want to run, just update the hosts.yml and set the provisioning variable to point to your playbook (or just run them outside of Vagrant)
If using the ones that comes pre-defined, it is also possible to override the default parameters using environment variables as defined here.
So, if you wanted to install a cluster with 12.2 GI and a 12.1 RAC One Node database, you’d do this (after having followed the instructions in the readme):
setup=true giver=22.214.171.124 dbver=126.96.36.199 dbtype=RACONENODE dbstorage=ASM vagrant up
Special thanks to Alvaro Miranda (@kikitux) for helping out with some Ruby intricacies.