To give you a better overview of what I am going to do I created a simple diagram:
I am running the following test drive on Mac OS 10.8.5
Prerequisites
On your host system make sure the following tools are installed
1) Oracle VirtualBox 4.3
2) Vagrant 1.3.5
3) git
Before going on just open 'Terminal' and check if the command line tools are available.
Vagrant 1.3.5
akmac2:~ ak$ git --version
git version 1.7.12.4 (Apple Git-37)
Configuring the desired VM
akmac2: $ cd /Users/ak/Workspace/github
akmac2:github ak$ git clone https://github.com/matthewbaldwin/vagrant-wls12c-centos64.git
Cloning into 'vagrant-wls12c-centos64'...
remote: Counting objects: 280, done.
remote: Compressing objects: 100% (179/179), done.
remote: Total 280 (delta 90), reused 255 (delta 71)
Receiving objects: 100% (280/280), 612.79 KiB | 90 KiB/s, done.
Resolving deltas: 100% (90/90), done.
akmac2:github ak$
-------
Next I made some changes to the Vagrantfile and the provisioning script site.pp in order to get the binaries from my external software repository drive. The path on my local machine to the software binaries is as follows:
- /Volumes/EXT_AK_1TB/Downloads/oracle/oracle.java/jdk-7u25-linux-x64.tar.gz
- /Volumes/EXT_AK_1TB/Downloads/oracle/oracle.weblogic/wls_121200.jar
Changes to Vagrantfile done:
config.vm.synced_folder "/Volumes/EXT_AK_1TB/Downloads", "/software"
Changes to puppet/manifests/site.pp done:
...
jdk7::install7{ 'jdk1.7.0_45':
version => "7u45" ,
....
sourcePath => "/software/oracle/oracle.java",
}
...
$puppetDownloadMntPoint = "/software/oracle/oracle.weblogic"
Now everything is set up to boot and provision the VM:
akmac2:vagrant-wls12c-centos64 ak$ vagrant upNext I made some changes to the Vagrantfile and the provisioning script site.pp in order to get the binaries from my external software repository drive. The path on my local machine to the software binaries is as follows:
- /Volumes/EXT_AK_1TB/Downloads/oracle/oracle.java/jdk-7u25-linux-x64.tar.gz
- /Volumes/EXT_AK_1TB/Downloads/oracle/oracle.weblogic/wls_121200.jar
Changes to Vagrantfile done:
config.vm.synced_folder "/Volumes/EXT_AK_1TB/Downloads", "/software"
Changes to puppet/manifests/site.pp done:
...
jdk7::install7{ 'jdk1.7.0_45':
version => "7u45" ,
....
sourcePath => "/software/oracle/oracle.java",
}
...
$puppetDownloadMntPoint = "/software/oracle/oracle.weblogic"
Now everything is set up to boot and provision the VM:
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'centos64' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading or copying the box...
Progress: 0% (Rate: 93585/s, Estimated time remaining: 3:23:20)
[default] Importing base box 'centos64'...
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8888 (adapter 1)
[default] -- 7001 => 7001 (adapter 1)
[default] Running 'pre-boot' VM customizations...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Setting hostname...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /software
[default] -- /tmp/vagrant-puppet/manifests
[default] -- /tmp/vagrant-puppet/modules-0
Running Puppet with site.pp...
Info: Loading facts in /tmp/vagrant-puppet/modules-0/wls/lib/facter/oracle_middleware_homes.rb
Warning: Unrecognised escape sequence '\/' in file /tmp/vagrant-puppet/modules-0/jdk7/manifests/install7.pp at line 93
…
…
Notice: Compiled catalog for wls1212.enpitlocal.de in environment production in 2.03 seconds
...
Notice: /File[stopNodeManager.sh]/ensure: created
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 572.02 seconds
akmac2:vagrant-wls12c-centos64 ak$
Vagrant automatically created the VM in the VirtualMachines folder of your VirtualBox.
and integrated it into the VirtualBox Manager
BTW: The downloaded vagrant boxes are stored in ~/.vagrant.d/boxes. During the download the stream is temporarily stored in ~/.vagrant.d/tmp. So make sure to have enough space in your home directory.
Working with the WLS 12c machine
Well this is pretty easy. Just run
$ vagrant ssh
to log into the running VM as user vagrant.
Typically you would like to work as oracle user. Just do
wls12c$ su oracle
By default the root user is locked for security reasons. Any admin tasks can be done as vagrant user by sudo. Nevertheless you can unlock the root user with the following command
$ sudo passwd -u root
Afterwards you can login with user root and pwd vagrant.
Minor Issues
(1)Vagrant provisioning with puppet
Info: Loading facts in /tmp/vagrant-puppet/modules-0/wls/lib/facter/oracle_middleware_homes.rb
Warning: Unrecognised escape sequence '\/' in file /tmp/vagrant-puppet/modules-0/jdk7/manifests/install7.pp at line 93
=> The Warning looks a bit strange but seems not to break the provisioning run!
(2)Trying to run the "service nodemanager_Wls12c start" I got an exception
/etc/init.d/nodemanager_Wls12c: line 31: /lib/lsb/init-functions: No such file or directory
[oracle@wls1212 ~]$
Solution: Commenting out line 31 in the init script worked for me ;)
Most important vagrant commands for a managed VM
$ vagrant up (on the first run the VM box is downloaded if needed, booted and provisioned by the configuration of the Vagrantfile. On any further runs the VM box is just booted but not provisioned.)
$ vagrant ssh (Logs into the running VM as user vagrant)
$ vagrant up --provision (Boot the VM and provision by the configuration of the Vagrantfile)
$ vagrant halt (shuts down the running VM)
$ vagrant reload (equivalent of running 'vagrant halt' and 'vagrant up')
$ vagrant reload --provision (equivalent of running 'vagrant halt' and 'vagrant up' and 'vagrant provision')
$ vagrant suspend (Suspend the running VM)
$ vagrant resume (Resume the suspended VM)
$ vagrant provision (Run the provision scripts against the running VM. Great to test script changes)
$ vagrant destroy (The VM will be completely destroyed. Space is freed.)
Conclusion
The combination of Vagrant / Puppet / Puppet Oracle Modules is extremely powerful. It is possible to create predictable, preconfigured "VMs from code". With this powerful set of scripts and tools it is quite easy to create new environments based on different Oracle FMW Versions. I guess that we (enpit) will automate the creation and configuration of our environments in the future.
Further information
- Blog: WLS 12c with Vagrant: http://vbatik.wordpress.com/2013/10/11/weblogic-12-1-2-00-with-vagrant/
- Download Vagrant: http://downloads.vagrantup.com/tags/v1.3.5
- Documentation Vagrant: http://docs.vagrantup.com/v2/
- WLS Puppet Module Source: https://github.com/biemond/puppet/ (=> In these Puppet modules the real work has been done! This is really impressive!)
- WLS Puppet Module: http://forge.puppetlabs.com/biemond (=> to be used by puppet for installation of the modules)
- Presentation: Oracle Fusion Middleware FMW provisioning with puppet (OOW2013) by Edwin Biemond: http://de.slideshare.net/biemond/fmw-puppet-oow13
- Download Latest Geppetto (4.0): http://puppetlabs.github.io/geppetto/download.html (for editing puppet modules with code assist and highlighting)
- Vagrantfile for WLS 12c : https://github.com/matthewbaldwin/vagrant-wls12c-centos64