How Do You Fully Automate Hybris Commerce Installation Using Vagrant?

Is your company struggling with Hybris Commerce installations and deployments for your development, testing, and production environments?
This step-by-step tutorial will show you how to automate your Hybris Commerce installations, which will:

  • Save your company time and money
  • Eliminate installation and deployment mistakes
  • Establish a consistent Hybris deployment process

In more technical terms, this article will demonstrate how to automate the installation of SAP Hybris 6.3 and its requisite software dependencies for Linux CentOS 7 with a Vagrant Up command. The information learned in this tutorial should provide a useful framework for Hybris installations and deployments.

This tutorial will work on both Windows and Mac machines. There are a few open source software products required to successfully complete this tutorial:

  1. Vagrant: https://www.vagrantup.com/downloads.html
  2. VirtualBox: https://www.virtualbox.org/wiki/Downloads
  3. Putty or Git Bash (Windows Users):
    - Putty: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
    - Git Bash: https://git-scm.com/download/
    - Mac Users: Built-in command prompt

You will also need the binaries for the SAP Hybris Commerce Suite, which is not an open source product. I’m using SAP Hybris Commerce Suite 6.3 for this tutorial. Only SAP Hybris Commerce customers and certified SAP Hybris partners have access to the SAP Hybris Software, https://wiki.hybris.com/display/downloads/Archived+6.3.0+Release

Once you have installed these software products on your machine, you are ready to fully automate your SAP Hybris deployment.

Getting Started

Open the command prompt. In my case, I’m using Git Bash.

1. Clone or download the HybrisArchitect.com Install-Hybris-With-Vagrant Github repository. Perform the following at the command prompt:

            git clone https://github.com/HybrisArchitect/Install-Hybris-With-Vagrant.git

2. A new directory called Install-Hybris-With-Vagrant is created.

3. Change into the Install-Hybris-With-Vagrant directory by using the following change directory command at the command prompt:

    cd

4. Perform the following list directory command at the command prompt:

    ls

5. You should see the following files:

SAP Hybris

6. Copy the hybris-commerce-suite-6.3.0.1.zip file, Hybris Commerce Suite, into this directory.
7. Now it's time to install Hybris. Perform the following command at the command prompt:

     vagrant up

8. 15-20 minutes later, you should see the following in your command prompt screen:

9. Go to your Web browser and type: https://localhost:9002/platform
            You should now see the HAC Initialization screen. Hybris has been successfully installed!

In the next section, I will review the files that fully automated the Hybris installation, starting with the Vagrantfile.

Vagrantfile

  1. Line 6 downloads the entire CentOS 7 Linux distro to your host machine.
  2. Line 9 defines the name of the virtual machine
  3. Line 10 establishes the amount of RAM dedicated to the virtual machine.
  4. Line 13 is commented out, but you may find this line useful if you want to assign a private IP address to your virtual machine.
  5. Lines 15 and 16 ensure the default Hybris ports are available on the virtual machine.
  6. Line 18 ensures the host machine is set up for agent forwarding.
  7. Line 21 allows the Hybris Installation Zip file to be copied to the virtual machine from your host machine.
  8. Line 24 provisions the primary shell script, bootstrap.sh, to install and configure the Hybris dependencies such as Java 8 and MySQL. We will review the bootstrap.sh momentarily that installs the dependencies.
  9. Line 26 displays a congratulations banner once the installation is complete.

Now let’s review the second file, bootstrap.sh.

bootstrap.sh

The Bootrap.sh file is a shell script that installs the Hybris software dependencies such as Java and MySQL. In more detail, the bootstrap.sh file will install Java 1.8, which is recommended for Hybris 6.3 The bootstrap.sh file will also configure the MySQL credentials and create a database called hybrisDB.

Let’s review the bootstrap.sh file.

  1. Lines 3-7 are variables used throughout the shell script such as Hybris directory location, Hybris database name, and Hybris database credentials. Please modify these according to your environment.
  2. Line 9 updates Centos 7 with more recent packages, if available.
  3. Line 12 installs the wget package.
  4. Lines 15 through 23 downloads and installs Java. I recommend setting up javac and jar commands path using alternatives as shown in Lines 19 through 23.
  5. Jumping to line 28, which sets the JAVA_HOME system variable.
  6. Line 31 sets the PATH variable
  7. Now the fun starts on line 39. We perform a wget to download the MySQL RPM file.
  8. Line 40-43, installs MySQL.
  9. Line 46 starts the MySQL Service
  10. Line 49 is very important in order to successfully automate the installation. Line 49 grabs the MySQL default password and assigns it to a local variable.
  11. On line 54, the default password is then used to login into mysqladmin
  12. On line 55, the Hybris database is created with the name, hybrisDB. You may change this to any db name that makes sense for you.
  13. Jumping to line 63. This is very important as the Hybris Installation Zip file is copied from your Host computer’s Vagrant directory to the virtual machine’s /opt/hybris63 directory.
  14. On line 65, installing the unzip binaries to unzip the Hybris Installation Zip file.
  15. Line 68, the Hybris Installation Zip file is unzipped.
  16. Line 71, the Hybris Installation Zip file is removed from the virtual machine for good measure.
  17. Skipping ahead to line 77 through 82, we open the project.properties file with the sed command to disable hsqldb database by commenting out its configuration.
  18. Line 85 through 94, we enable the MySQL configuration by removing the hashtag or pound symbol. The database name is set to use hybrisDB. The Hybris user name and password is set to match the username and password we defined in lines 6 and 7 of this file.
  19. Line 98 downloads the MySQL Connector Java Jar file and copies it to the /hybris/bin/platform/lib/dbdriver.
  20. On line 100, the Ant environment variables are set.
  21. Line 104, ant clean all command is executed to run Hybris in the develop mode automatically.
  22. Lastly on line 106, the Hybris application is started.

    Wrapping Up

    There's a lot of information covered in the article. Please clone the Github repo discussed in the article, and spend time familiarizing yourself with the Vagrantfile and bootstrap.sh files.  Once you understand the details of these files, you will be well on your way to fully automating your own Hybris deployments. Good luck!

Marc Raygoza

Marc is the Founder of HybrisArchitect.com.
He enjoys helping others learn more about SAP Commerce Cloud (Hybris). Marc is a SAP Commerce Certified Professional and has held the role of SAP Commerce Cloud Architect at Deloitte, PwC, Brillio (a Bain Company), and Nasty Gal. Marc holds an M.S. Software Engineering from Carnegie Mellon University and a B.S. in Accountancy from California State University, Fresno. He can be reached at: mraygoza@hybrisarchitect.com

You may also like...

Popular Posts