Sunday, March 23, 2025

Chef client cookbook to run from local system : Install Oracle 19c Client Software in Linux Machine

To Install Oracle Client we need to download and place this in Oracle Directory. 

First go to the chef cookbook location and create below directories

  cd cookbooks
  mkdir -p Oracle_Client_Install/recipes
  mkdir -p Oracle_Client_Install/files/default 

Once we create the default directories. We need to create a sh script in default directory and rb script in recipes directory.
our directory structure will now looks like this

  ~/cookbooks
     Oracle_Client_Install
        recipes
           OracleClientInstall.sh
        files
           default
           	OracleClientInstall.rb

Download the Oracle Client software and keep that in directory "/opt/sw/oracle". Then unzip the file. Add the below path in the client_install.rsp file

UNIX_GROUP_NAME=oracle
INVENTORY_LOCATION=/opt/sw/app/oraInventory
ORACLE_HOME=/opt/sw/oracle/Oracle19c/client/home
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
ORACLE_BASE=/opt/sw/oracle 

Copy the below content into the OracleClientInstall.sh.

#!/bin/bash
cd /opt/sw/oracle
mkdir -m 775 -p /opt/sw/oracle/Oracle19c/client/home/network/admin
mkdir -m 775 -p /opt/sw/app/oraInventory
export CV_ASSUME_DISTID = OLE7.8
unset ORACLE_HOME
unset TNS_ADMIN
unset ORACLE_SID
cd /opt/sw/oracle/Oracle19c/client
./runInstaller -silent -responseFile /opt/sw/oracle/Oracle19c/client/response/client_install.rsp

Copy the below content into the OracleClientInstall.rb
#recipes/display_certificates.rb
#Cook book : Oracle_Client_Install
#Recipe : OracleClientInstall.rb
execute 'Install Oracle Client' do
  command 'bash ~/cookbooks/Oracle_Client_Install/files/default/OracleClientInstall.sh
  user 'oracle'
  group 'oinstall'
  action :run
end
 
Save the files and run the chef client using the below code
chef-client -zr recipe[Oracle_Client_Install::OracleClientInstall]
It will install the Oracle Client Software

No comments: