Ansible Automation for WebLogic: Automate Java Installation Step by Step
Can you automate the Java installation required for WebLogic across multiple servers without manually logging in to every machine?
If you manage WebLogic environments, you already know that middleware setup can involve many repetitive activities—installing Java, preparing directories, copying installers, configuring users, and preparing servers for WebLogic installation.
Instead of performing these activities manually on every server, Ansible can automate the entire process.
In this tutorial, we will start with a simple but practical example: automating Java installation on WebLogic application servers using an Ansible playbook.
This post is the first part of the Ansible Automation for WebLogic series.
What We'll Learn
By the end of this tutorial, you will understand how to:
- Understand the basic Ansible architecture
- Configure an Ansible inventory
- Establish SSH connectivity between Ansible and target servers
- Validate connectivity using the Ansible
pingmodule - Create your first Ansible playbook
- Understand plays, tasks, and modules
- Use the Ansible
unarchivemodule - Automate Java installation on remote WebLogic servers
- Prepare the environment for subsequent WebLogic installation automation
No Agents required!
Ansible is simple language that is started as opensource and later it is acquired by Red Hat. The core communication happens with SSH. SSH widely available trusted in all UNIX and Linux systems. Ansible can be run any system as it doesn't relay on central machine.| Ansible automation for Java and WebLogic 12c |
Here my experiment goes with two Ubuntu 14 Trusty Tahr machine. In one machine Ansible will be installed and other machine is used as target node, in real-time scenario the target list can be many hundreds and this has been proven by NASA and other Ansible implements. Using Ansible lots of organizations get into structured and role based automation implementations successful.
For Redhat flavors
The actions that need to executed in remote host machine are called TASK. playbooks are executable batches which are ymal files. Plays are having one or more tasks. Playbooks can be collections of tasks. Plays are executed top to bottom when it parse the playbook. to work with playbook we must define inventory which we define hosts file.
Defining Inventory in hosts file
This can be placed in user home directory or common location /etc/ansible/hosts. The inventory will be defined with groups such as webapps, appservers, dbservers etc. As we are going to work on WebLogic application server we will define it as appservers group in the host inventory.
| Host Inventory defining for ansible |
Understanding Ansible Inventory
Before Ansible can execute tasks, it needs to know which servers it should manage.
This information is maintained in an inventory.
An inventory can contain:
- Hostnames
- IP addresses
- Groups
- Variables
- Environment-specific server definitions
For this example, we create an appservers group containing our WebLogic servers.
Lets create a simple one our WebLogic servers host IP into the appservers as a group the file.could be stored in the $HOME path with the content as follows:
vi hosts
[appservers] 192.168.33.100 192.168.33.102
You can then execute a playbook against only the required group.
For example:
ansible-playbook -i hosts java_install.ymlThe playbook can target:
hosts: appserversThis means the Java installation task will be executed only against the servers belonging to the appservers group.
Configure SSH Connectivity
Ansible normally communicates with Linux target servers using SSH. Therefore, SSH connectivity should be established before running the playbook.
Generate an SSH key:
ssh-keygen -t rsa -b 4096 -C "My ansible key"
| ssh-keygen for vagrant user |
copy the ssh key
ssh-copy-id -i ~/.ssh/id_rsa.pub vagrant@192.168.33.102
now regular Unix level command try to connect with ssh this should not prompt for password
ssh vagrant@192.168.33.10
| ssh connection validation for ansible |
eval $(ssh-agent)
ssh-add
ansible -i ~/hosts -m ping all
| ansible hosts ping all |
Create your first yaml file for ansible play
The playbook is developed with yaml coding to set up couple of plays. Each play contain multiple task, which will tell the Ansible engine.
| Ansible Playbook structure |
Each task can be developed with module which is a part of core module and we can also create custom modules if required. There 700+ modules are freely available in opensource ansible. Here I am going to use the unarchive core module which requires src, dest values and this sample playbook have only have single play that will install Java that is unarchive the tar.gz file that is availabe in the specified shared location mentioned as src. If you don't have shared drive then ansile should use copy module and then use this task.
vagrant@docking ~/wls_auto $ cat java_install.yml
- hosts: appservers
remote_user: vagrant
tasks:
- name: Unpack archive
unarchive:
src: /u01/app/software/jdk/jdk-8u172-linux-x64.tar.gz
dest: /home/vagrant
remote_src: yes
Please correct if indentation looks wrong
The execution is as follows:
We will be sharing the part 2 which will be install the WebLogic in the remote machine.
Each task generally uses an Ansible module to perform a specific operation.
For example:
copy→ copy filesunarchive→ extract archivesfile→ manage files and directoriespackage→ manage packagesservice→ manage servicescommand→ execute commands
For this example, we will use the unarchive module.
What's Next?
In the next part of this Ansible Automation for WebLogic series, we will move one step further and automate the WebLogic installation process.
We will look at how to:
- Copy the WebLogic installer
- Extract the required files
- Copy the response file
- Prepare the Oracle inventory configuration
- Use Ansible modules to execute the installation
- Build a repeatable WebLogic installation workflow
Reader Challenge
Before continuing, think about this:
If you had 50 WebLogic servers that needed the same Java installation, would you install Java manually on each server—or automate it once and execute it everywhere?
That's the real value of Ansible.
Instead of repeatedly performing the same administrative tasks, we define the desired steps in a playbook and let Ansible execute them consistently across multiple servers.
References:
How to install and configure Ansible on Ubuntu?Unarchive module sample
How to solve “Permissions 0777 for ‘~/.ssh/id_rsa’ are too open.” ?
Well explanation. Keep updating Devops Online Training
ReplyDeleteexcellent article. thanks for sharing. DevOps Training in Bangalore | Certification | Online Training Course institute | DevOps Training in Hyderabad | Certification | Online Training Course institute | DevOps Training in Coimbatore | Certification | Online Training Course institute | DevOps Online Training | Certification | Devops Training Online
ReplyDeleteThanks for sharing a valuable topic in this Blog Really it is very helpful and interesting. All the best and do share such articles in future also.
ReplyDeleteDigital Marketing Training in Chennai
Digital Marketing Course in Chennai
Perde modelleri
ReplyDeleteSms Onay
Mobil Odeme Bozdurma
Nft nasil alınır
Ankara Evden Eve Nakliyat
Trafik sigortası
Dedektor
Site Kurma
aşk kitapları
thanks for this amazing article keep posting full stack java classes in pune
ReplyDelete