Saturday, May 25, 2024

Ansible automation for WebLogic - Part 3 installation of WebLogic 12.2.1.3.0 quick

As part of "Ansible automation for WebLogic" series - in this post we are going to install the WebLogic 12.2.1.3.0 quick installer. There is very interesting research on how and when to use ansible modules for WebLogic. This is true weekend I set my time to have how this ansible automation works for WebLogic installation task, serious focused on this task.

Prerequisites
We have already seen in the earlier posts [if not visited yet please do visit] following links:
  1. Java Installation using ansible playbook
  2. WebLogic installer unarchive copy response file, oraInst.loc file to remote node
Writing Playbook with command
In this post, I've explored on the below mentioned best suitable ansible modules
  1. command module
  2. pause module
The command module is better one,  I've choosen after trying with shell module.
Installing WebLogic is a single command that need to executed on the remote node.  As we already copied the WebLogic installer and response file, oraInst.loc to /tmp folder of remote nodes, which can be used by command. To give more generic automation solution we need to use the variables in the playbook.

The pause module will pause the playbook execution flow. To install WebLogic it requires some amount of time to complete the execution task of the command, and we need to wait till that so pause after install command is best option to use.

Ansible playbook executes command module to install WebLogic


There are some interesting sections in the playbook that we are going to use in this example post containing  :
  1. vars
  2. debug module
Ansible allows us to use vars with in the playbook and also we can define in separate file, then its reference file can be included in the playbook. There can be global variables which can be reusable in multiple playbooks depends on the roles that requires. We will discuss more on roles in the next post.

When some of the tasks in ansible modules are played then what happened we don't know. To get the insight on that we have debug moduleoption.  When debug module used we need to use the printing option with msg and the register variable to send the result or output to stdout. This stdout is raw string of JSON so that we can use the play.

Ansible playbook is so simple to design and develop code as we are seeing them since last two previous blog posts. If the playbook have a var multiple times same value required to define under vars and use them in multiple lines of a task. Here we will be using java_dir, mw_dir, mw_installer and oracle_home.

vi  wls_install.yml
---
- hosts: appservers
  remote_user: vagrant
  vars:
     java_dir: /home/vagrant/jdk1.8.0_172
     mw_dir: /tmp
     mw_installer: fmw_12.2.1.3.0_wls_quick.jar
     oracle_home: /home/vagrant/fmw
  tasks:
   - name: install WebLogic
     command: "{{ java_dir }}/bin/java -jar  {{ mw_dir }}/{{ mw_installer }} -ignoreSysPrereqs -force -novalidation ORACLE_HOME={{ oracle_home }} -responseFile {{ mw_dir }}/wls_install.rsp -invPtrLoc {{ mw_dir }}/oraInst.loc"
     register: command_result
   - debug:  msg={{ command_result.stdout.split('\n')[:-1]}}
   - name: Wait for installation complete
     pause:
        minutes: 3


The execution of WebLogic installation by playbook is simple as shown below:

vagrant@docking ~/wls-auto $ ansible-playbook -i ~/hosts wls_install.yml



Part 2 of screen shot
ansibible-playbook execution for WebLogic installation



Your valuable feedback is most important to us to improve our next articles. So request you to use the comment box.

Please write your comments and likes about this ansible series. Stay tuned to "WebLogic Tricks & Tips" for another wonderful automation soon.

Reference links
  1. debug module
  2. pause module
  3. command module

Blurb about this blog

Blurb about this blog

Essential Middleware Administration takes in-depth look at the fundamental relationship between Middleware and Operating Environment such as Solaris or Linux, HP-UX. Scope of this blog is associated with beginner or an experienced Middleware Team members, Middleware developer, Middleware Architects, you will be able to apply any of these automation scripts which are takeaways, because they are generalized it is like ready to use. Most of the experimented scripts are implemented in production environments.
You have any ideas for Contributing to a Middleware Admin? mail to me wlatechtrainer@gmail.com
QK7QN6U9ZST6