Saturday, November 2, 2013

Setup WebLogic 12c environment with Vagrant and Puppet

For one of my presentations at DOAG 2013 I wanted to play around and checkout new features with the latest WebLogic version 12.1.2. To save some time and get experienced in some of the cool DevOps tools I gave a try for Vagrant and Puppet to setup a fresh new WebLogic 12c machine. BTW: All this is possible due to the impressive work Edwin Biemond has done in the last weeks and month (Checkout his powerful puppet modules plus the Vagrant based provisioning script of Matthew Baldwin. (Checkout his recent blog post about that

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

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.

akmac2:~ ak$ vagrant -v
Vagrant 1.3.5
akmac2:~ ak$ git --version
git version (Apple Git-37)

Configuring the desired VM
akmac2: $ cd /Users/ak/Workspace/github
akmac2:github ak$ git clone
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/
- /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/",
$puppetDownloadMntPoint = "/software/oracle/oracle.weblogic"

Now everything is set up to boot and provision the VM:
akmac2:vagrant-wls12c-centos64 ak$ vagrant up
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)

Successfully added box 'centos64' with provider 'virtualbox'!
[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 in environment production in 2.03 seconds
Notice: /File[]/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

# After logging in as vagrant 
$ 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

oracle@wls1212 ~]$ service nodemanager_Wls12c start
/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.)

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


  1. great this is working for you , I also solved those escape errors , just updated the puppet wls module.

    I am now busy with a new clean totally refactored one , only for Linux and optimized for hiera . The goal is just to configure some network or some host yaml files and roll out all the fully configured WebLogic servers you want . Easy and no need for a big site.pp.
    adding many queues should be very easy , take less text and with a great readable overview.

    see this URL for more info

    or my vagrant test image for all the hiera details

    cheers Edwin

  2. Yes, thanks! The combination of Vagrant, Puppet and your modules just works without any hassles!

    Your refactored scripts are more flexible and easier to read/understand ;) Thanks for sharing!

    Nevertheless I wonder what is the best practice for maintaining customizations of provisioning scripts like your puppet modules in long term. At least the Vagrantfile is specific and will definitely contain customizations. Just forking and adjusting to own needs? This will lead to diversification and maybe confusion..

    Best Regards,

  3. Andreas...nice blog and thank you for the reference. I will be refactoring scripts to Edwin's "Puppet 3" way in orawls. I think moving his Puppet codebase forward is the path forward and then posting individual repo's that use a snapshop of the modules. As you can see, there is change in his repo's almost on a daily process.

    The majority of change for the individual use cases are in the Vagrantfile and in the site.pp file in the manifests directory.

    The OSB install I posted is using vagrant and multi machines While doing this work, Mavericks, VBox 4.3.0 and 4.3.2 and a new Vagrant version were released. The one thing that Edwin and noticed was that the user needs to keep the VBox Guest Additions current. In that vein..I have done some testing with the following: